【发布时间】:2023-03-31 21:25:01
【问题描述】:
我的数据如下所示:
predecessor,successor
AAMBD01P.ACCOUNT_ANALYTICAL_BALANCE,DIMS32P.NHJ_DEPOSIT
AAMBD01P.CUSTOMER_ACCOUNT_REL,DIMS32P.NHJ_DEPOSIT
AAMBD01P.CUSTOMER_SUB_DETAIL2_BBKKA,DIMS32P.NHJ_DEPOSIT
AAMBD01P.CUSTOMER_BBKKA_DETAIL,DIMS32P.NHJ_DEPOSIT
AAMBD08P.CUSTOMER_DETAIL2_FULL,DIMS32P.NHJ_DEPOSIT
AAMBD08P.ACC_CURR_DEP_STAT_HIST,DIMS32P.NHJ_DEPOSIT
MISV19P.V_CUSTOMER_SEGM,DIMS32P.NHJ_DEPOSIT
我正在尝试将其加载到我的 Neo4J 实例中,但出现此错误:
neo4j.exceptions.CypherSyntaxError: {code: Neo.ClientError.Statement.SyntaxError} {message: Query cannot conclude with LOAD CSV (must be RETURN or an update clause) (line 1, column 1 (offset: 0))
"LOAD CSV WITH HEADERS FROM 'file:///data.csv' AS line"
^}
我的代码:
from neo4j import GraphDatabase
driver = GraphDatabase.driver("bolt://localhost:7687", auth=("neo4j", "187179"))
def add_data(tx):
tx.run("LOAD CSV WITH HEADERS FROM 'file:///data.csv' AS line")
tx.run("MERGE (s:src {id: line.source})")
tx.run("MERGE (d:dst {id: line.destination})")
tx.run("CREATE (s)-[:FEEDs_INTO]->(d)")
with driver.session() as session:
session.write_transaction(add_data)
driver.close()
【问题讨论】: