Search code examples
neo4jcypherneo4j-apoc

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


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


Solution

  • 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});