Reputation: 161
I am trying to load a single csv into a Neo4j DB. I have followed this guideline but still can't understand why is not working for me.
I can create the nodes correctly (its attributes are all the columns but one) and I want to build a relationship between all the nodes with the only attribute left that wasn't added to the node.
My data in file.csv
looks like:
Column,instaGramId,imageDateCreated,imageTagCount,imageFilter,googleLabel_list 0,1165524631240624607_638926073,1453161384,7,Normal,"[cartoon, comics, artwork]"
...
I'm following these steps:
Step 1: creating nodes this is working correctly
USING PERIODIC COMMIT
LOAD CSV WITH HEADERS FROM "file:///file.csv" AS row
CREATE (:Post {instaGramId: row.instaGramId,
imageDateCreated: toInt(row.imageDateCreated),
imageTagCount: row.imageTagCount,
imageFilter: row.imageFilter});
Only attribute left is googleLabel_list
which needs to be a in a different node
Step 2: create an Index this is working correctly too, I guess
CREATE INDEX ON :Post(instaGramId);
Step 3: create relationships this is not working correctly
USING PERIODIC COMMIT
LOAD CSV WITH HEADERS FROM "file:///file.csv" AS row
MATCH (post:Post {id: row.instaGramId})
MATCH (objects:Post {id: row.googleLabel_list})
MERGE (post)-[:CONTAINS_OBJECTS]->(objects);
Upvotes: 0
Views: 567
Reputation: 66999
The following clause will probably never match anything (and therefore no relationships will ever be created):
MATCH (objects:Post {id: row.googleLabel_list})
This is because your existing POST
nodes have id
values (e.g., "1165524631240624607_638926073" -- which come from row.instaGramId
) that probably look nothing like your row.googleLabel_list
values (e.g., "[cartoon, comics, artwork]").
Upvotes: 1