csv - neo4j 导入带有关系的 CSV

标签 csv import neo4j cypher relationship

我正在导入从关系数据库导出的 .CSV 文件。导入进展顺利,但是当我尝试使用分配的标签在创建的节点之间创建关系时,它正在为关系创建新节点,而不是使用现有标签。我已经为此绞尽脑汁三天了 - 有什么想法吗?

代码:

USING PERIODIC COMMIT
LOAD CSV WITH HEADERS FROM "file:///seshatdata/sellable_unit_features.csv" AS line 
WITH line, SPLIT(line.ship_dt, '-') AS date

CREATE (sellableunit:SellableUnit {sellable_unit_id: line.sellable_unit_id, sellable_unit_nm: line.sellable_unit_nm, sellable_unit_version_id: line.sellable_unit_version_id})
MERGE (feature:Feature {Feature_id:line.feature_id, feature_nm: line.feature_nm})

CREATE (SellableUnit)-[r:CONTAINS]->(Feature)

SET r.start_year = TOINT(date[0]);

显然,CREATE (SellableUnit)-[r:CONTAINS]->(Feature) 行是罪魁祸首 - 我只是不知道为什么。

最佳答案

您的 Cypher 查询有拼写错误。 Cypher 区分大小写 variable declarations .

Variable names are case sensitive, and can contain underscores and alphanumeric characters (a-z, 0-9), but must always start with a letter. If other characters are needed, you can quote the variable using backquote (`) signs

尝试一下:

USING PERIODIC COMMIT
LOAD CSV WITH HEADERS FROM "file:///seshatdata/sellable_unit_features.csv" AS line 
WITH line, SPLIT(line.ship_dt, '-') AS date

CREATE (sellableunit:SellableUnit {sellable_unit_id: line.sellable_unit_id, sellable_unit_nm: line.sellable_unit_nm, sellable_unit_version_id: line.sellable_unit_version_id})
MERGE (feature:Feature {Feature_id:line.feature_id, feature_nm: line.feature_nm})

CREATE (sellableUnit)-[r:CONTAINS]->(feature)

SET r.start_year = TOINT(date[0]);

您将节点存储到名为 sellableUnit(小写)的变量中,但在 CREATE 语句中使用名为 SellableUnit(大写)的变量S)。 功能也是如此。

关于csv - neo4j 导入带有关系的 CSV,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45486344/

相关文章:

neo4j - 在 Neo4j 中查找集群

neo4j - @QueryResult 不起作用

python - 在 pandas 中将时间序列数据与元数据相结合的正确方法是什么?

python - 如何将多个 CSV 文件从文件夹读取到 pandas 中,并以数据框名称作为文件名

excel - 如何使用 "|"分隔和 utf-8 代码将 Excel 导出到 csv 文件

objective-c - iOS:当我将 AppDelegate.h 包含到另一个头文件中时,什么会导致 Xcode 编译器抛出错误?

java - neo4j 2.0 M3 记录器未找到

java - 如何从 csv 返回特定数据?

reactjs - 尝试导入错误: 'reactstrap' does not contain a default export (imported as 'Table' )

java - 与通过通配符(星号)导入相比,导入单个类的编码风格优势