【发布时间】:2018-11-06 13:07:42
【问题描述】:
我正在使用 apoc.periodic.iterate 和 apoc.load.csv 加载 csv 文件,但我总是失败并说有 NullPointerException :
neo4j> CALL apoc.periodic.iterate('
CALL apoc.load.csv("http://128.194.9.150:9999/On_Time_On_Time_Performance_2018_1.csv", {}) yield map as row return row
','
MATCH (sc:City {name: row.OriginCityName}), (tc:City {name: row.DestCityName})
MERGE (sc)-[f:Flight {flightDate: row.FlightDate, flightNum: toInt(row.FlightNum)}]->(tc)
', {batchSize:200, iterateList:true, parallel:true});
+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| batches | total | timeTaken | committedOperations | failedOperations | failedBatches | retries | errorMessages | batch | operations | wasTerminated |
+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| 2851 | 570131 | 888 | 313800 | 256400 | 1282 | 0 | | {total: 2851, committed: 1569, failed: 1282, errors: {`java.lang.NullPointerException`: 1282}} | {total: 570131, committed: 313800, failed: 256400, errors: } | FALSE |
+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
但是,当我使用 neo4j 的 load csv 命令加载此文件时,它们是正确的:
neo4j> LOAD CSV WITH HEADERS FROM "http://128.194.9.150:9999/On_Time_On_Time_Performance_2018_1.csv" as row
MATCH (sc:City {name: row.OriginCityName}), (tc:City {name: row.DestCityName})
MERGE (sc)-[f:Flight {flightDate: row.FlightDate, flightNum: toInt(row.FlightNum)}]->(tc)
;
0 rows available after 3395077 ms, consumed after another 0 ms
Created 255988 relationships, Set 511976 properties
csv 文件来自网站:https://www.transtats.bts.gov/DL_SelectFields.asp?Table_ID=236&DB_Short_Name=On-Time
我应该如何加载 csv 文件以避免 NullPointerException ?
【问题讨论】: