Adding a simple Edge Collection from a .Csv File.

325 views
Skip to first unread message

Michele Ippoliti

unread,
Jun 4, 2016, 7:57:35 AM6/4/16
to ArangoDB
Hi.
I'm a beginner,
I'd like to add some entries to an edge collection I created with ArangoDB Web Interface.

the .csv file is something like:

"_from", "_to", "_key"
00001,00002, 0.1
00002,00003, 0.2

where "_from" and "_to"  are strings IDs.. and _key is a percentage.

I can't import this, it gives me an "illegal document handle":

So I tried to make a document collection named "Tracks" with all the IDs,  and then I created a .csv like this.."

_from", "_to", "_key"
Tracks/00001,Tracks/00002, 0.1
Tracks/00002,Tracks/00003, 0.2


but it's the same.. 

I want only to create a simple graph.. 
I have a nodes file (a list of ids) and an edge file, with two IDs per row and a percentage.
How can I do?

Thanks.

Michele Ippoliti

unread,
Jun 4, 2016, 8:00:50 AM6/4/16
to ArangoDB
I'm using arangoimp btw..

Simran Brucherseifer

unread,
Jun 4, 2016, 8:46:35 AM6/4/16
to ArangoDB
Welcome Michele!

In ArangoDB, document keys are strings. They must not be numeric, although it's perfectly fine to turn a number into a string and use that instead (note the quote marks):

{ "_key": "123" }

In CSV, entries like 123 or 0.1 are actually interpreted as numbers. You must store handles as strings however. So instead of

Tracks/0001,Tracks/0002,0.1

you should store it like this:

"Tracks/0001","Tracks/0002","0.1"

Here's a sample CSV I successfully imported:

"_from","_to","_key"
"vert/001","vert/002","0.1"
"vert/002","vert/003","0.2"
"vert/003","vert/004","0.3"


Note the blank line at the end. In my test, arangoimp ignored the last row, so the 3rd edge was not imported. The extra line fixed this.

Also note that this will not create any vertex documents with keys "0.1" etc. but just the edges (they are dangling edges). As this shows, it is not checked whether the documents you reference in _from and _to exist. It is checked whether the referenced vertex collections exist however, which means there has to be document collection "vert" or you will see a "collection does not exist" error during import. The command-line option --create-collection true will create the target edge collection if necessary, but not implicitly create those vertex collections.

Hope this helped.

Best, Simran

Michele Ippoliti

unread,
Jun 5, 2016, 8:57:42 AM6/5/16
to ArangoDB
thank youU! 
Now it works!!
Reply all
Reply to author
Forward
0 new messages