假设我需要加载csv文件c:\ myData.csv
alfa,beta,gamma
0001,1000,thousant
0002,2000,two-K
...
节点中的
(:myData{alfa:0001,beta:1000,gamma'thousant'})
(:myData{alfa:0002,beta:2000,gamma'two-k'})
有没有办法将所有列导入属性而不逐一指定它们?
像
这样的东西LOAD CSV WITH HEADERS FROM 'file:/c:/myData.csv' AS line set line:myData create line
or
LOAD CSV WITH HEADERS FROM 'file:/c:/myData.csv' AS line create (:myData {line.*})
答案 0 :(得分:2)
在尝试了不同的选项后,以下为我工作,Neo4j 3.3.2:
USING PERIODIC COMMIT 10000
LOAD CSV WITH HEADERS FROM 'file:///apples.csv' AS appleAllLineProperties
CREATE(apple:Apple)
set apple += appleAllLineProperties
观察结果:
Neo4j希望该文件位于以下文件夹中
C:\ Users \\ AppData \ Roaming \ Neo4j Desktop \ Application \ neo4jDatabases \ database- \ installation-3.3.2 \ import
答案 1 :(得分:1)
您可以使用
LOAD CSV WITH HEADERS FROM 'file:/c:/myData.csv' AS line
create (:MyData {line})
或
LOAD CSV WITH HEADERS FROM 'file:/c:/myData.csv' AS line
MATCH (m:MyData {id:line.id})
SET m += {line}