[英]Correctly importing CSV File into Neo4j database
I am currently trying to import a csv file into neo4j. 我目前正在尝试将csv文件导入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. 现在,我正在尝试导入这些行,以便将节点1和2连接起来,而相同的节点仅存在一次。 So I guess I will need to do the MERGE command which seems to work with the following CQL Request:
所以我想我需要执行MERGE命令,该命令似乎可以与以下CQL请求一起使用:
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. 现在,我要实现的是,两个csv文件中多次出现的节点之间的连接(如上例中的value1到value 2)由相应连接中的属性“ count”表示。 So the connection between value1 and value2 has a attribute count=2.
因此,value1和value2之间的连接具有一个属性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.
非常感谢你。
这里只是一个小错误,它是ON MATCH SET
,而不是ON MERGE SET
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.