2
votes

I am importing a .CSV file I exported from a relational database. The import is going fine, but when I try to create relationships between the created nodes, using their assigned labels, it is creating new nodes for the relationship rather than using the existing labels. I've been banging my head against this for 3 days - any ideas?

Code:

USING PERIODIC COMMIT
LOAD CSV WITH HEADERS FROM "file:///seshatdata/sellable_unit_features.csv" AS line 
WITH line, SPLIT(line.ship_dt, '-') AS date

CREATE (sellableunit:SellableUnit {sellable_unit_id: line.sellable_unit_id, sellable_unit_nm: line.sellable_unit_nm, sellable_unit_version_id: line.sellable_unit_version_id})
MERGE (feature:Feature {Feature_id:line.feature_id, feature_nm: line.feature_nm})

CREATE (SellableUnit)-[r:CONTAINS]->(Feature)

SET r.start_year = TOINT(date[0]);

Obviously it's the line CREATE (SellableUnit)-[r:CONTAINS]->(Feature) that's the culprit here - I just don't know why.

1

1 Answers

2
votes

Your Cypher query has a typo error. Cypher is case sensitive for variable declarations.

Variable names are case sensitive, and can contain underscores and alphanumeric characters (a-z, 0-9), but must always start with a letter. If other characters are needed, you can quote the variable using backquote (`) signs

Try it:

USING PERIODIC COMMIT
LOAD CSV WITH HEADERS FROM "file:///seshatdata/sellable_unit_features.csv" AS line 
WITH line, SPLIT(line.ship_dt, '-') AS date

CREATE (sellableunit:SellableUnit {sellable_unit_id: line.sellable_unit_id, sellable_unit_nm: line.sellable_unit_nm, sellable_unit_version_id: line.sellable_unit_version_id})
MERGE (feature:Feature {Feature_id:line.feature_id, feature_nm: line.feature_nm})

CREATE (sellableUnit)-[r:CONTAINS]->(feature)

SET r.start_year = TOINT(date[0]);

Your are storing a node into a variable called sellableUnit (lowercase s) but using in the CREATE statement a variable called SellableUnit (uppercase S). The same for feature.