Neo4j APOC import csv NoSuchElementException error

Viewed 103

I created 2 test files following neo4j's documentation for an apoc csv import (configuration file has: apoc.import.file.enabled=true, apoc.export.file.enabled=true, dbms.directories.plugins=plugins , dbms.directories.import=import), the apoc plug in is in the plug in folder, and the physical csv files are in the neo4j import directory for this instance). I am using these test datasets because I'll be using it for a significantly larger dataset(neo4j admin which is essentially similar syntax).

The edgelist csv file is in this format, with no empty cells:

:START_ID,:END_ID,TYPE
C11,D84,assoc_with
C7,D62,assoc_with
C5,D12,assoc_with

The node csv looks like this, again with no empty cells:

:ID,name,id,address,has_fruitstand,:LABEL
C1, A , 1, address1, N,company
C2, B , 2, address2, Y,company
C3, C, 3, address3, Y,company

The cypher syntax with me only calling 1 file to test is:

call apoc.import.csv([{fileName: 'file:/test_edgelist.csv', labels: ['company', 'friend']}],[],{})

The error that I get back is: 'Failed to invoke procedure 'apoc.import.csv' : Caused by java.util.NoSuchElementException: No value present.'

I have no idea why this error, since the file does exist. I've tried different variations of the code, including placing the entire file location, but to no avail. Any ideas? Feedback is appreciated - thanks!

1 Answers

This is how I did it. I'm using Neo4j 4.2.4 version.

Create the test_nodelist.csv as below.

:ID,name,id,address,has_fruitstand,:LABEL
C1, A , 1, address1, N,company
C2, B , 2, address2, Y,company
C3, C, 3, address3, Y,company

Then create the edgelist as below:

:START_ID,:END_ID,TYPE:STRING
C1,C2,assoc_with

Lastly, the syntax for creating the nodes and edges is below: Note that delimiter is comma and ids are string type.

CALL apoc.import.csv(
  [{fileName: 'file:/test_nodelist.csv', labels: ['company']}],
  [{fileName: 'file:/test_edgelist.csv', type: 'assoc_with'}],
  {delimiter: ',', arrayDelimiter: ',', stringIds: true}
)

enter image description here

Related