Reputation: 1
I loaded a station csv file on Neo4j:
LOAD CSV WITH HEADERS FROM 'https://github.com/pauldechorgnat/cool-datasets/raw/master/ratp/stations.csv' AS row
CREATE (:Station {
nom_clean:row.nom_gare,
nom_gare: row.nom_gare,
x: toFloat(row.x),
y: toFloat(row.y),
Trafic: toInteger(row.Trafic),
Ville: row.Ville,
ligne: row.ligne});
I would like to relate them by loading another csv file:
LOAD CSV WITH HEADERS FROM 'https://github.com/pauldechorgnat/cool-datasets/raw/master/ratp/liaisons.csv' AS row
MATCH (s1:Station {nom_gare: row.start})
OPTIONAL MATCH (s2:Station {nom_gare: row.stop})
WHERE s2 IS NOT NULL
MERGE (s1)-[:LIAISON {ligne: row.ligne}]->(s2);
but I have the message (no changes, no records), I do not see the error in my order?
Thanks for your help
Upvotes: 0
Views: 51
Reputation: 7696
The main problem is, that the unique ID for your station is in row.nom_clean
but you match on row.nom_gare
Here is a version that worked for me (but I do not know the data):
LOAD CSV WITH HEADERS FROM 'https://github.com/pauldechorgnat/cool-datasets/raw/master/ratp/stations.csv' AS row
CREATE (:Station {
nom_clean:row.nom_clean,
nom_gare: row.nom_gare,
location: point({y: toFloat(row.y), x: toFloat(row.x)}),
Trafic: toInteger(row.Trafic),
Ville: row.Ville,
ligne: row.ligne});
And:
LOAD CSV WITH HEADERS FROM 'https://github.com/pauldechorgnat/cool-datasets/raw/master/ratp/liaisons.csv' AS row
MATCH (s1:Station {nom_clean: row.start})
MATCH (s2:Station {nom_clean: row.stop})
MERGE (s1)-[:LIAISON {ligne: row.ligne}]->(s2);
I stored the x,y as a point data type. This would allow to perform range and distance queries.
This is a small dataset, for anything real you need an index (or better, unique constraint) on Station:nom_clean
For consistency, I would either use lower or upper case property names. Neo4j's recommendation is cammelCase.
Upvotes: 0