首页 文章

neo4j导入CSV与关系

提问于
浏览
2

我正在导入从关系数据库导出的.CSV文件 . 导入正常,但是当我尝试使用指定的标签在创建的节点之间创建关系时,它会为关系创建新节点,而不是使用现有标签 . 我已经连续3天撞到这头了 - 任何想法?

码:

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) 知道原因 .

1 回答

  • 2

    您的Cypher查询存在拼写错误 . Cypher对variable declarations区分大小写 .

    变量名称区分大小写,可以包含下划线和字母数字字符(a-z,0-9),但必须始终以字母开头 . 如果需要其他字符,可以使用反引号(`)符号引用变量

    试试吧:

    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 (小写s)的变量中,但在 CREATE 语句中使用名为 SellableUnit (大写S)的变量 . feature 也一样 .

相关问题