Reputation: 1940
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
Upvotes: 2
Views: 3953
Reputation: 71
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])})
Upvotes: 0
Reputation: 4052
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});
Upvotes: 7