2

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!

E2023
  • 105
  • 12

1 Answers1

1

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

jose_bacoy
  • 12,227
  • 1
  • 20
  • 38
  • For some reason, the edgelist won't go in and I still get the same error even after I made the update in the csv header to TYPE:STRING – E2023 Feb 18 '22 at 19:59
  • ok, so it appears that if you don't have edges with nodes that it can direct to in your dataset, it basically errors. Which is not ideal if you have a big dataset. – E2023 Feb 19 '22 at 22:29