create rdf file for CSV import
Forums
Hi,
I am trying to import a csv file using an ideascript. I understand that there needs to be a corresponding rdf file otherwise the import wont work. Is there a way to create the rdf file using ideascript?
thanks,
Mike
I didn't write that's not
I didn't write that's not possible to do such batch imports with IDEA however your question above referred only to the creation of the rdf file!
As you wrote you would need a rdf file as import definition. You can create that rdf file manually and then use it with your script for multiple imports. Regardless to say that all csv files should have the same structure because if not a script really makes no sense.
If you don't want to create the rdf file manually the CSVDefinition-Object gives you the opportunity set delimiters and so on by your code.
When it comes to the batch import of all files from a given folder the Dir-Object will help you in this project.
Hi klmi, thanks for your help
Hi klmi, thanks for your help. I have not been able to find an object catalogue or CSVDefinition-Object. I have tried to find this in IDEA Help (language explorer) as well as support.casewareanalytics.com (which I assume is the online help?). If you could point me in the right direction that would be extremely helpful?
thanks again,
Mike
Hi Mikew,
Hi Mikew,
You can only create an RDF through script with version 10.4 or higher. If you want to perfrom an import of a CSV with a version prior to 10.3 then you will have to first manually create the RDF file.
In the language browser, if you have 10.4, here is some example code for creating a RDF file. It is under the CSV Definition object.
Sub Main
csvPath = "Source Files.ILB\Delimited.csv"
rdfPath = "Import Definitions.ILB\Delimited.RDF"
firstRowAsFieldNames = TRUE
CsvEncodingUTF8 = 2
' Create, configure, and save the definition file.
Set csvDefinition = Client.NewCsvDefinition
csvDefinition.DefinitionFilePath = rdfPath
csvDefinition.CsvFilePath = csvPath
csvDefinition.FieldDelimiter = ","
csvDefinition.TextEncapsulator = """"
csvDefinition.FirstRowIsFieldNames = firstRowAsFieldNames
csvDefinition.CsvFileEncoding = CsvEncodingUTF8
Client.SaveCSVDefinitionFile csvDefinition
' Define the output name and perform the import task.
dbName = "Delimited.IMD"
Client.ImportUTF8DelimFile csvPath, dbName, FALSE, "", rdfPath, firstRowAsFieldNames
' Open the result.
Client.OpenDatabase (dbName)
End Sub
Hi mikew,
Hi mikew,
the easiest way to create the rdf file would be to import the csv file one time manually. As one of the last steps you will be able to save the rdf file. If you are using IDEA 10.4 (and higher) otherwise have a look on the CSVDefinition-Object.