Product 1 2 3 4 5 Total
Toyota 10 15 22 40 55 142
BMW 9 91 19 12 11 142
Audi 10 9 15 20 95 149
I have individual nodes created for ratings 1 to 5.
I want to create relationships as
Node = Toyota Connected to Node = Ratings (1) with property of rating count as 10.
Node = Toyota Connected to Node = Ratings (2) with property of rating count as 15.
Node = Toyota Connected to Node = Ratings (2) with property of rating count as 22.
Currently I am manually hardcoded the values of ratings per columns using MATCH car and MATCH ratings, which results in 5 sets of 3 MATCH statements, totalling 15 MATCH statements. The original dataset has 30,000 rows, and it takes a lot of time to load the data.
This is my Cypher.
I added a backtick where the item name starts with a number.
Ratings are CREATED for each car, but if they are different, please change them.
Thanks, but this will work for small dataset, not for huge dataset with 100K rows. The individual CREATE relationships statements has to run 5 * 100K individually to create.
I would like to iterate 1 entire row, and based on the column name, it should create the relationship with the count as property.
Here is my take on the data model:
1. To keep the number of nodes to minimum, you can create one node for each row. Here is the Cypher:
LOAD CSV WITH HEADERS FROM 'file:///amelia.csv' AS line
MERGE (p:Product {name:"Product"})
MERGE (c:Car {name: line.Product, rating1:toInteger(line.`1`), rating2:toInteger(line.`2`), rating3:toInteger(line.`3`), rating4:toInteger(line.`4`), rating5:toInteger(line.`5`), total: toInteger(line.Total)})
MERGE (p)-[:PRODUCT_WITH_RATINGS]->(c)