我正在尝试设置图形数据库,我有两个csv文件。我已经成功设置了csv,第一个工作正常。
第一个CSV:
LOAD CSV WITH HEADERS FROM "file:///C:/Users/rraina/Desktop/acc.csv" AS csvLine
MERGE (providerName:ProviderName { name: csvLine.providerName })
MERGE (container:Container { name: csvLine.CONTAINER })
MERGE (asset:Asset { name: csvLine.isAsset })
CREATE (account:Account { accountName: csvLine.accountName, id: csvLine.id})
CREATE (account)-[:ACCOUNTS_IN]->(providerName)
CREATE (account)-[:ACCOUNT_TYPE]->(container)
CREATE (account)-[:IS_ASSET]->(asset)
CSV看起来像这样:
CONTAINER,accountName,accountStatus,accountNumber,isAsset,balance,id,lastUpdated,providerId,providerName,refreshinfo,isManual
reward,RAHUL RAINA,ACTIVE,xxxx0363,TRUE,3334,16294736,1433967380,9863,HSBC Bank Personal Banking,0|OK|1433967380|1433967380,FALSE
bank,SAVINGS ACCOUNT - RES,ACTIVE,xxxx5006,TRUE,6048.07,16294732,1433967401,9863,HSBC Bank Personal Banking,0|OK|1433967401|1433967401,FALSE
creditCard,VISA GOLD,ACTIVE,xxxx0363,FALSE,4885.56,16294492,1433967428,9863,HSBC Bank Personal Banking,0|OK|1433967428|1433967428,FALSE
bank,SBCHQ-GEN-PUB-IND-NONRURAL-INR,ACTIVE,xxxx6404,TRUE,24572.98,16294488,1433966054,9421,State Bank of India,0|OK|1433966054|1433966054,FALSE
我已经能够使用上述查询制作我需要的图表。
但是,当我导入第二个csv并尝试将trans.csv中的关系添加到acc.csv时
trans.csv看起来像这样:
CONTAINER,id,amount,baseType,category,description,originalDescription,isManual,date,transactionDate,merchantName,status,accountId
bank,133817384,1400,DEBIT,ATM/Cash Withdrawals,ATM07JUN15 NFS 11:38:44A96103218ATM,ATM07JUN15 NFS 11:38:44A96103218ATM,FALSE,6/8/2015,6/8/2015,Cash Withdrawal,POSTED,16294732
bank,133815940,224,DEBIT,Transfers,TO TRANSFER INB Tinyowl Technology Privat,TO TRANSFER INB Tinyowl Technology Privat,FALSE,6/8/2015,6/8/2015,Transfer,POSTED,16294488
查询导入第二个csv并建立关系:
LOAD CSV WITH HEADERS FROM "file:///C:/Users/rraina/Desktop/trans.csv" AS csvLine
MERGE (baseType:BaseType { name: csvLine.baseType })
MERGE (category:Category { name: csvLine.category })
MERGE (merchantName:MerchantName { name: csvLine.merchantName })
MATCH (account:Account { id: csvLine.accountId }),(transaction:Transaction { id: csvLine.accountId })
CREATE (transaction:Transaction { description: csvLine.description, postedDate: csvLine.date,transactionDate: csvLine.transactionDate ,id: csvLine.id })
CREATE (transaction)-[:CATEGORY_IN]->(category)
CREATE (transaction)-[:TRANSACTED_AT]->(merchantName)
CREATE (transaction)-[:BASETYPE_OF]->(baseType)
我收到此错误:
WITH is required between MERGE and MATCH (line 5, column 1 (offset: 253))
"MATCH (account:Account { id: csvLine.accountId }),(transaction:Transaction { id: csvLine.accountId })"
如果acc.csv是:account.id equals
trans.csv,我希望Transactions.csv中的所有交易都与accounts.csv相关:transaction.id
答案 0 :(得分:2)
为什么不给它要求的WITH
声明?
放线:
WITH baseType, category, merchantName, csvLine
在您的上一个MERGE
和MATCH
之间。