1
votes

I am new to neo4j database. I am trying to update specific nodes from existing nodes in graph db by loading csv file . my updated value csv file look like this

ID,SHOPNAME,DIVISION,DISTRICT,THANA
01760,Xyz,RAJSHAHI,JOYPURHAT,Panchbibi
01761,Abc,DHAKA,GAZIPUR,Gazipur Sadar

and my query code

CALL apoc.periodic.iterate('LOAD CSV WITH HEADERS FROM "file:///nodes_AGENT_U_20190610.csv" AS line return line','MERGE (p:Agent{ID:TOINT(line[0])}) ON MATCH SET p.SHOPNAME=TOINT(line[1]) ' ,{batchSize:10000, iterateList:true, parallel:true});

but I am getting error

"Expected Long(0) to be a org.neo4j.values.storable.TextValue, but it was a org.neo4j.values.storable.LongValue": 1

I have tried TOINTEGER function for resolving this problem but not working for me , Kindly help me to solve this issue . I am using Neo4j 3.5 and apoc version 3.5.0.4 Thank you

2
Which version of Neo4j? 3.5.0? If so, upgrade to the latest 3.5.x patch release, to rule out any patched out bugs in earlier releases.InverseFalcon
My neo4j version is Neo4j 3.5.6Kalyan

2 Answers

4
votes

You need to use column name to access value from the line/row, when loading data with LOAD CSV WITH HEADERS.

Check following query:

CALL apoc.periodic.iterate('LOAD CSV WITH HEADERS FROM 
"file:///nodes_AGENT_U_20190610.csv" AS line return line',
'MERGE (p:Agent{ID:TOINT(line.ID)}) 
ON MATCH SET p.SHOPNAME=TOINT(line.SHOPNAME) ' ,
{batchSize:10000, iterateList:true, parallel:true});
0
votes

I agree with above answer, also some more knowledge, as you might be thinking i have seen that kind of usage somewhere:

You may however also use below query the way you were using but here you don't have headers that's why: LOAD CSV FROM 'https://neo4j.com/docs/cypher-manual/4.0/csv/artists-fieldterminator.csv' AS line FIELDTERMINATOR ';' CREATE (:Artist { name: line[1], year: toInteger(line[2])})