So I'm trying to upload graphs from CSV file in apache age. For that I'm using the following commands,
SELECT create_graph('test_graph');
SELECT create_vlabel('test_graph','movie');
SELECT load_labels_from_file('test_graph','movie','/home/sarthak/Downloads/sample/movie.csv',false);
This works and it's for creating nodes. Notice I've passed false flag as ID is optional as stated in the documentation.
Here's movie.csv
~ cat movie.csv
name,released
The Matrix,1999
However while uploading edges I've to follow this csv format.
Here start_id and end_id
corresponds to ids present in node.csv, but that I've not set.
So how can I create edges between them.
I tried with
SELECT create_elabel('test_graph','acted');
SELECT load_edges_from_file('test_graph', 'acted','/home/sarthak/Downloads/sample/ACTED_IN[person&movie].csv');
But results in error ERROR: label_id must be 1 .. 65535
Here's my edge.csv
> cat ACTED_IN\[person\&movie\].csv
start_id,start_vertex_type,end_id,end_vertex_type,properties
1,Keanu Reeves,3,The Matrix,Neo
2,Carrie-Anne Moss,1,The Matrix,Trinity
3,Laurence Fishburne,2,The Matrix,Morpheus
4,Hugo Weaving,2,The Matrix,Agent Smith
I've checked that there's no garbage value in the csv file.
This error is occurring because you need to provide the edge label name as the start_vertex_type
and end_vertex_type
parameters. Here is the correct format:
start_id,start_vertex_type,end_id,end_vertex_type,character_name
1,Person,3,Movie,Neo
2,Person,1,Movie,Trinity
3,Person,2,Movie,Morpheus
4,Person,2,Movie,Agent Smith
Please note that I have changed the header from properties
to character_name
. The parser will use this header name as the property name when creating the edge.
However, in order to use the correct IDs, you need to ensure that each vertex has this property. You can either iterate through each vertex and add the property, or modify your vertex .csv
file to include this additional column.