我有以下代码,我需要使用(如果存在)更高效的代码,因为我的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 *;
您对我有什么建议吗?
答案 0 :(得分:1)
import tool通常比LOAD CSV
快得多。
但是,您的查询建议每个csv行以模式(b)<-(c)结尾,因此您需要对此csv进行一些预处理...首先过滤空值,然后拆分分为3个csv(2个用于节点,1个用于关系)。
为此,您有3个主要选项: