I have almost similar case to the question here in stack overflow . Create a node for each column only once while importing csv into Neo4j - Stack Overflow
Here the edges are made if the cell have value of 1, but in my case I want to create edges properties with value inside the cell
I am new to neo4j space and I tried my best to do this but with no luck, then I found a hard way, which I am sure is not computationally effective (it got unnecessary iteration and is running for few hours now). Here is what I tried.
LOAD CSV FROM 'file:///newquotes.csv' AS line
FIELDTERMINATOR '\t'
MERGE (h:Headers)
SET h.names = line
WITH line
LIMIT 1
UNWIND line[2..] AS name
MERGE (c:Cell {name: name})
WITH apoc.map.fromNodes('Cell', 'name') AS cells
MATCH (h:Headers)
LOAD CSV FROM 'file:///newquotes.csv' AS line
FIELDTERMINATOR '\t'
WITH h, cells, line
SKIP 1
MERGE (g:Gene {id: line[1], name: line[0]})
FOREACH(
x IN REDUCE(s = [], i IN RANGE(2, SIZE(line)-1) |
CASE line[i] WHEN "type1" THEN s + cells[h.names[i]] ELSE s END) |
MERGE (g)-[:has {value :"type1"}]-(x))
FOREACH(
y IN REDUCE(s = [], i IN RANGE(2, SIZE(line)-1) |
CASE line[i] WHEN "type2" THEN s + cells[h.names[i]] ELSE s END) |
MERGE (g)-[:has {value : "type2"}]-(y))
FOREACH(
z IN REDUCE(s = [], i IN RANGE(2, SIZE(line)-1) |
CASE line[i] WHEN "type3" THEN s + cells[h.names[i]] ELSE s END) |
MERGE (g)-[:has {value : "type3"}]-(z))
I asked this in slack, but I dint got any help from there. Hope someone here could help this newbie to get started .