I'm attempting to setup my first database with imported data from a CSV but I'm having an issue with creating some relationships. Initially, I had the spreadsheet set up like this:
ID Ingredient Country Price Inclusions Source
1 Something USA 10 4 Book 1,2
1 Other USA 35 29 Book 1,3
1 Something USA 12 9 Book 1,2,3
With my code, though, it not only created a node for each source book, it then created nodes like 'Book 1,2' which scrambled everything. There are multiple items that are present between books. I then tried making new columns to see if that would help,as shown here.
ID Ingredient Country Price Inclusions Source1 Source2 Source3
1 Something USA 10 4 Book 1 Book 2
2 Other USA 35 29 Book 1 Book 3
3 Something France 12 9 Book 1 Book 2 Book 3
4 Other Finland 70 16 Book 2 Book 3
5 Something USA 30 9 Book 2
6 Other Spain 44 192 Book 3
But each time a query has worked, it creates something like 15,000 connections with one node. After extensive trial and error, this is what gets me all the initial relationships to Book 1.
LOAD CSV WITH HEADERS FROM "file:///CombinedTotals.csv" as csvLine
CREATE (n:Ingredient {id: toInteger(csvLine.id), ingredient: csvLine.ingredient, price: toInteger(csvLine.price), inclusions: toInteger(csvLine.inclusions)})
MERGE (country:Country {name: csvLine.country})
CREATE (n)-[:MADE_IN]->(country)
MERGE (source:Source {name: csvLine.source})
CREATE (n)-[:SOURCED_FROM]->(source)
How can I set a conditional to create the additional relationships for existing books that ignores null values?