Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
02-20-2021 11:49 AM
I'm creating new relationships between existing nodes by importing a CSV file. I had done queries to import csv for specific types of relationships and now , I trying to parse a mixed type CSV using apoc.do.case
but problem appears while starting the first non-header row:
Failed to invoke procedure
apoc.do.case: Caused by: java.lang.NullPointerException (Failure when processing file '/home/bmalbusca/Applications/neo4j-community-4.1.3/import/rel-complex-waternodes.csv' on line 2.)
I'm literally using the other singular relationships queries inside apoc.do.case
. I'm missing somethig? This is the file rel-complex-waternodes.csv
:
"relation,start,end,type,subtype,flow_rate"
"CONNECTED,0,4,Aduação,Bombagem,42"
"CONNECTED,1,2,Aduação,Bombagem,37"
"CONNECTED,2,5,Aduação,Gravidade,32"
"CONNECTED,3,31,Aduação,Gravidade,40"
"CONNECTED,3,7,Aduação,Gravidade,9"
"CONNECTED,4,1,Aduação,Bombagem,42"
"CONNECTED,5,6,Aduação Blocos de Rega,Gravidade,"
"CONNECTED,5,3,Aduação,Gravidade,32"
"RELATED,5,07c850df-7af2-493a-84a4-b13f27e3cf8d,,,"
"CONTAINED,269,6,,,"
And here is the query:
LOAD CSV WITH HEADERS FROM "file:///rel-complex-waternodes.csv" as row
WITH row
CALL apoc.do.case([row.relation = "CONTAINED",'MATCH (s:Station{id:row.start}), (w:WaterNode{id:row.end}) CREATE (s)-[r:CONTAINED]->(w) RETURN r',
row.relation = "RELATED",'MATCH (n), (f:Feature{id:row.end}) WHERE (n:WaterNode OR n:Station) AND n.id=row.start CREATE (n)-[r:RELATED]->(s) RETURN r',
row.relation = "REPRESENTED",'MATCH (w:WaterNode{id:row.start}), (f:Feature{id:row.end}) CREATE (w)-[r:REPRESENTED]->(f) RETURN r',
row.relation = "CONNECTED",'MATCH (n1), (n2) WHERE (n1:WaterNode OR n1:Station) AND (n2:WaterNode OR n2:Station) AND n1.id=row.start AND n2.id=row.end
CREATE (n1)-[r:CONNECTED {type: row.type, subtype: row.subtype, flow_rate: toFloat(row.flow_rate)}]->(n2) RETURN r']
,'',{row:row}) YIELD value
Return count(value.r)
Solved! Go to Solution.
02-20-2021 12:00 PM
It complains about line 2 of the csv. As a test if you remove line 2 from the csv does it still fail?
Also is each line in the csv wrapped in " characters ? If you remove the leading and trailing " characters does it still fail ??
02-20-2021 12:00 PM
It complains about line 2 of the csv. As a test if you remove line 2 from the csv does it still fail?
Also is each line in the csv wrapped in " characters ? If you remove the leading and trailing " characters does it still fail ??
All the sessions of the conference are now available online