file format when using Import from CSV

Started by michael_e, May 14, 2015, 07:32:20 AM

Previous topic - Next topic

michael_e

Hi

I've read the manual and searched the forum without finding an answer to this question. I hope I haven't just missed an obvious answer.

Is there any documentation of how to construct a csv file of new elements for bulk import into Archi?

I've tried looking at the format of the files produced by the Export to CSV command but no matter what I try I get the message "File should contain element information"

Below is a simplified example showing what I have tried.
I'm particularly unclear about how the ID column is supposed to be treated when importing new elements from a CSV file?

I can see that the export format of the elements.csv file includes ID as the first column - but when I'm importing data I can't know what ID Archi is going to assign to the new elements.

Should I omit the ID column altogether, should I leave the column blank, or should I pass in my own ID values (this seems like a bad idea because of ID collisions)?

Any pointers would be appreciated

-----  Simplified elements.csv file attempts ---------------
"Type","Name","Documentation"
"WorkPackage","title 1","https://example.com"
"WorkPackage","title 2",""
"WorkPackage","title 3",""
"WorkPackage","title 4",""
"WorkPackage","title 5",""
"WorkPackage","title 6","https://example.com"
"WorkPackage","title 7","https://example.com"
"WorkPackage","title 8","https://example.com"

OR

"ID","Type","Name","Documentation"
"","WorkPackage","title 1","https://example.com"
"","WorkPackage","title 2",""
"","WorkPackage","title 3",""
"","WorkPackage","title 4",""
"","WorkPackage","title 5",""
"","WorkPackage","title 6","https://example.com"
"","WorkPackage","title 7","https://example.com"
"","WorkPackage","title 8","https://example.com"

OR

"ID","Type","Name","Documentation"
"DNP122","WorkPackage","title 1","https://example.com"
"DNP88","WorkPackage","title 2",""
"DNP116","WorkPackage","title 3",""
"DNP117","WorkPackage","title 4",""
"DNP119","WorkPackage","title 5",""
"DNP88","WorkPackage","title 6","https://example.com"
"DNP97","WorkPackage","title 7","https://example.com"
"DNP88","WorkPackage","title 8","https://example.com"



michael_e

I've just read the source code and I've found both the reason for the error message and the answer to how to treat the ID Column. I'll leave this here in case anyone else runs into the same problems.

I was getting the error message "File should contain element information" because the csv file has to end with the case-sensitive string "elements" (I had "Elements"). The code that does the check is in CSVImportProvider.isElementsFileName()

The help text for exporting has a note about how to deal with ID for importing.

QuoteElement and relationship IDs are optional, but you need to provide an ID for an element if it is referenced by a relationship or property, and to provide an ID for a relationship if it is referenced by a property. If providing an ID then it needs to be unique to the file using alpha-numeric characters, for example - "id1", "8fe456d", "actor3". If an ID is not provided, a blank field "" should be present. In this case, an ID will be generated on import.

Phil Beauvoir

Hi,

that's right. The details about the file name are also in the User Guide:

QuoteAt the very least, you need to provide a CSV file named "xxx-elements.csv" where the "xxx-" part of the file name is optional. If you also provide a relations file it needs to be in the format described above and named "xxx-relations.csv". If you also provide a properties file it needs to be in the format described above and named "xxx- properties.csv". Again, the "xxx-" part of the file name is optional. All three file names need to match - for example: "myname-elements.csv", "myname-relations.csv" and "myname-properties.csv".

Phil
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.