我的数据如下所示:
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()发布于 2021-10-14 12:24:04
您正尝试在4个部分中运行单个查询。tx.run()需要完整的查询。
您可以将代码修改为:
def add_data(tx):
tx.run("LOAD CSV WITH HEADERS FROM 'file:///data.csv' AS line \
MERGE (s:src {id: line.source}) \
MERGE (d:dst {id: line.destination}) \
CREATE (s)-[:FEEDs_INTO]->(d)")https://stackoverflow.com/questions/69569922
复制相似问题