neo4j csv文件中的列中有多个值

ee7vknir  于 2023-03-29  发布在  其他
关注(0)|答案(1)|浏览(123)

我是neo4j的新手。我搜索了我的问题,但找不到它。我有一个包含电影名称,电影类型,导演,制片人等的csv文件。其中一些列包含多个值。我想将这些值导入neo4j数据库,但我不能。例如,制造商列包含多个值。当我将其导出到neo4j时,它将3个值作为一个节点写入。我想将每个值显示为不同的节点。您能帮助我吗?

LOAD CSV WITH HEADERS FROM '.../FilmData.csv' AS line MERGE (n:Movie{title:line.Film_Adi_TR,released:Vizyon_Tarihi, genre:Film_Turu}) Merge(y:Yapimci{title:line.Yapimci}) Merge (n)-[:Yapimci]->(y)

tzcvj98z

tzcvj98z1#

你需要将字符串拆分成单独的字符串(分隔符是逗号),然后展开来一次创建一个关系。展开就像一个“for循环”。

LOAD CSV WITH HEADERS FROM 'file:///FilmData.csv' AS line 
MERGE (n:Movie{title:line.Film_Adi_TR,released:line.Vizyon_Tarihi, genre:line.Film_Turu}) 
WITH n, split(line.Yapimci,",") as manufacturers
UNWIND manufacturers as m
MERGE (y:Yapimci{title: m}) 
MERGE (n)-[:Yapimci]->(y)

样品:

Film_Adi_TR,Vizyon_Tarihi,Film_Turu,Yapimci
"The Matrix",1999,Action,"Warner Bros,Roadshow Entertainment,Silver Pictures"

结果:

相关问题