RDFCREATORLIB

6 posts / 0 new
Last post
Eric_03
Offline
Joined: 11/02/2021 - 11:57
RDFCREATORLIB

Hello,
I work with IDEA in its version 11, I saw on the forum some post which spoke about rdfcreatorlib. I would like to be able to create RDF files on the fly under Python, ideascript or vba Excel but without success. Have you been successful in using this feature?
Thank you
Eric

Brian Element's picture
Brian Element
Offline
Joined: 07/11/2012 - 19:57

Hi Eric_03,

Here is a function from the IDEALib.py (if you have V11 installed do a search for it in the Program Files - CaseWare folder) that does what you are looking for in Python.  Hopefully this helps you out.


def _import_csv_into_idea(csvPath,tempPath,databaseName,client):
    rdfPath = path.join(tempPath,"temp_definition.rdf")    
    UTF8 = 2

    rdfTask = client.NewCsvDefinition()
    rdfTask.DefinitionFilePath = rdfPath
    rdfTask.CsvFilePath = csvPath
    rdfTask.FieldDelimiter = DELIMITER
    rdfTask.TextEncapsulator  = '"'
    rdfTask.CsvFileEncoding = UTF8
    rdfTask.FirstRowIsFieldNames = True

    dbObj = None
    try:
        client.SaveCSVDefinitionFile(rdfTask)
        client.ImportUTF8DelimFile(csvPath,databaseName,True,"",rdfPath,True)    
        dbObj = client.OpenDatabase(databaseName)        
    except:
        msg = "Error importing database."
        logging.error(msg)

    return dbObj
Eric_03
Offline
Joined: 11/02/2021 - 11:57

Hello,
Thank you for this information, I watch.
Eric

Eric_03
Offline
Joined: 11/02/2021 - 11:57

The file I need to import into idea is not CSV but delimited by a number of characters. The structure of the file is determined by a dateframe. I'm trying to create an RDF import file from this dataframe
 
Regards

Images: 
Brian Element's picture
Brian Element
Offline
Joined: 07/11/2012 - 19:57

So in the code this line holds the delimiter:

rdfTask.FieldDelimiter = DELIMITER

Just change DELIMITER for the one used in your scenario.

Eric_03
Offline
Joined: 11/02/2021 - 11:57

I don't know how to do. Can you please give me an example
Thank you