Skip to main content

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 Wed, 11/03/2021 - 06:44

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 Thu, 11/04/2021 - 03:11

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

Eric_03 Thu, 11/04/2021 - 04:42

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

Brian Element Thu, 11/04/2021 - 06:26

So in the code this line holds the delimiter:

rdfTask.FieldDelimiter = DELIMITER

Just change DELIMITER for the one used in your scenario.