Hi @sean.c.townsend,
In your first dataset, are you wanting source to have an Id or name with 1
or Book 1
?
Really what you need to do is preformat and parse that field.
Also, you'll want to look at your graph model. price looks to be country AND ingredient dependent. So you don't want that as an ingredient property. Same for inclusions (although I can't even guess what that's related to).
LOAD CSV WITH HEADERS FROM "file:///CombinedTotals.csv" as csvLine
WITH csvLine, split(csvLine.Source,',') as sourceArray
UNWIND sourceArray as sourceName
MERGE (n:Ingredient {name: csvLine.Ingredient})
MERGE (country:Country {name: csvLine.country})
MERGE (n)-[:MADE_IN]->(country)
MERGE (source:Source {name: sourceName})
MERGE (n)-[:SOURCED_FROM]->(source)
Another approach, and a more efficient one, is to loop over the csv multiple times.
One loop for each relationship you create (so minimum two).
That will prevent the MADE_IN
merge from being hit for each source on a row.
LOAD CSV WITH HEADERS FROM "file:///CombinedTotals.csv" as csvLine
MERGE (n:Ingredient {name: csvLine.Ingredient})
MERGE (country:Country {name: csvLine.country})
MERGE (n)-[:MADE_IN]->(country);
// Second cypherstatement, we already created the Ingredient so can do a straight match.
LOAD CSV WITH HEADERS FROM "file:///CombinedTotals.csv" as csvLine
WITH csvLine, split(csvLine.Source,',') as sourceArray
UNWIND sourceArray as sourceName
MATCH (n:Ingredient {name: csvLine.Ingredient})
MERGE (source:Source {name: sourceName})
MERGE (n)-[:SOURCED_FROM]->(source);
Have a good day!
Hope that helps!
-Mike