Neo4j:导入csv最有效的解决方案是什么



我有以下代码,我需要使用(如果存在的话(更高效的代码,因为我的csv中有很多行,Neo4j添加所有行需要太多时间。

using periodic commit 1000
load csv with headers from "file:///registry_office.csv" as f 
fieldterminator "|" 
WITH f AS a
WHERE NOT a.JobName IS NULL and NOT a.JobCode IS NULL and NOT 
a.JobDescription IS NULL and NOT a.JobLongDescription IS NULL 
AND NOT a.Long_Description IS NULL AND NOT a.Position IS NULL 
AND NOT a.birthDate IS NULL AND NOT a.startWorkingDate IS NULL
merge (b:Job{Name:a.JobName, Code:a.JobCode, Job:a.JobDescription, 
JobLongDescription:a.JobLongDescription})
merge (c:Person{PersonName:a.PersonName, PersonSurname:a.PersonSurname, 
CF:a.CF, birthDate:a.birthDate, address:a.address, age:a.age, 
married:a.married, birthPlace:a.a.birthPlace})
merge (b)<-[:RELATED_TO{startWorkingDate:a.startWorkingDate, 
JobPosition:a.Position}]-(c) 
return *;

你有什么建议吗?

导入工具通常比LOAD CSV快得多。

然而,您的查询表明,每个csv行都以模式(b(&lt--(c( ,所以你需要对这个csv进行一些预处理。。。首先过滤空值,然后分成3个csv(2个用于节点,1个用于关系(。

要做到这一点,您有3个主要选项:

  • Excel-不适用于大型CSV
  • CLI工具类似csvkit
  • 程序-如果你能使用Python或JavaScript,你将能够在20米左右的时间内完成这项工作

最新更新