Reputation: 55
I am currently trying to import a csv file into neo4j. Now for example lets see the following file:
node1,node2
value1,value2
value2,value3
value1,value2
Now what I am trying is to import those lines so that nodes 1 and 2 will be connected, while identical nodes only exist once. So I guess I will need to do the MERGE command which seems to work with the following CQL Request:
LOAD CSV WITH HEADERS FROM "file:///test_text.csv" AS line
MERGE (u :word { value: line.node1 })
MERGE (h :word { value: line.node2 })
MERGE (u)-[t :digram]->(h)
Now I want to achieve, that connections between 2 nodes, which occur multiple times in my csv file (like value1 to value 2 in the example above) are represented by an attribute "count" in the corresponding connection. So the connection between value1 and value2 has a attribute count=2.
I have tried to do that by appending the following line:
ON MERGE SET t.count = t.count + 1 ON CREATE SET t.count = 1
But that throws a syntax error. I am kind of lost at the moment and I am hoping you guys could help. Thank you very much.
Upvotes: 0
Views: 44
Reputation: 30417
Just a small error here, it's ON MATCH SET
, not ON MERGE SET
.
Upvotes: 2