Neo4j:导入 csv 最有效的解决方案是什么?
Neo4j: what is the most efficient solution to import 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 *;
你对我有什么建议吗?
import tool 通常比 LOAD CSV
快得多。
但是,您的查询建议每个 csv 行以模式 (b)<--(c) 结尾,因此您需要对此 csv 进行一些预处理...首先过滤空值,然后分成 3 个 csvs(2 个用于节点,1 个用于关系)。
为此,您有 3 个主要选择:
- Excel - 不适用于巨大的 CSV
- CLI 工具 - 类似于 csvkit
- 程序 - 如果您对 Python 或 JavaScript 没问题,您将能够在 20 米左右完成此操作。
我有以下代码,我需要使用(如果存在)更高效的代码,因为我的 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 *;
你对我有什么建议吗?
import tool 通常比 LOAD CSV
快得多。
但是,您的查询建议每个 csv 行以模式 (b)<--(c) 结尾,因此您需要对此 csv 进行一些预处理...首先过滤空值,然后分成 3 个 csvs(2 个用于节点,1 个用于关系)。
为此,您有 3 个主要选择:
- Excel - 不适用于巨大的 CSV
- CLI 工具 - 类似于 csvkit
- 程序 - 如果您对 Python 或 JavaScript 没问题,您将能够在 20 米左右完成此操作。