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)