【问题标题】:trying to csv load relationships in NEO4J试图在 NEO4J 中加载 csv 关系
【发布时间】:2019-02-25 06:50:03
【问题描述】:

我正在尝试 csv 加载关系。我的节点代表 80 个牧师和 200 个教堂。我正在尝试这样做-有效:

MATCH (p:Priest{name: "Baranowski, Alexander Sylvester" }),(c:Church{name: "St Wenceslaus"}) 
MERGE (p)-[:POSTED {posting:'1955-61', zip: '60618'}]->(c) 

但有 800 个 rels。 我的 csv 表列出了可能 10 倍的牧师,因此需要连接到 10 个不同的教堂。 我的 rels 是年份和邮政编码。我读过和尝试过的任何东西都没有奏效。想法?

感谢您的帮助。

【问题讨论】:

    标签: csv neo4j cypher


    【解决方案1】:

    你可以试试这个。 将您的 CSV 文件放入 neo4j 实例的导入文件夹中。

    load csv with headers from "file:///postings.csv" as row
    MERGE (p:Priest{name: row.priest })
    MERGE (c:Church{name: row.church }) 
    MERGE (p)-[:POSTED {posting:row.posting, zip: row.zip}]->(c) 
    

    【讨论】:

    • 上述解决方案返回“Neo.ClientError.Statement.SemanticError: Cannot merge node using null property value for name”。所有变体都返回错误或 zilch。 csv 文件被 csvlint 验证为正确。
    【解决方案2】:

    我假设发布始终存在于数据中。

    load csv with headers from "file:///postings.csv" as row 
    MERGE (p:Priest{name: row.priest }) 
    MERGE (c:Church{name: row.church }) 
    MERGE (p)-[rel:POSTED{posting:row.posting}]->(c)
    On Create set rel.zip=row.zip
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-09-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多