1
votes

For a course on Excel I was trying to load a CSV in Neo4j (first time using this application) when I was blocked at the first step of replicating an example shown in said course: loading.

The command which was used in the example was this;

  1. LOAD CSV WITH HEADERS FROM "file:/path/to/file/file.csv"
  2. as row
  3. CREATE (m:movie {name:row.movie})

But it gave syntax errors. I found out I could correct it by using double \ and add "file:";

  1. LOAD CSV WITH HEADERS FROM "file://C:\\path\\to\\file\\file.csv"
  2. as row
  3. CREATE (m:movie {name:row.movie})

Neo4j accepts this syntax, processes for a few moments, and returns YET ANOTHER error;

Neo.TransientError.Statement.ExternalResourceFailure

I tried the same commands (original and my own) in the online Neo4j console but no luck. I can reach the file using that path without problem; it really is there. The CSV file consist out of just 5 strings of regular letters, that's all. No fancy formatting or characters.

What's going on?

2
Alrighty, I figured out that it CAN work if the file is placed in dropbox. Yet I thought Neo4j is capable of uploading local files? Does anyone know how to do this?user5284283
Your file url is not goog, see this question : stackoverflow.com/questions/24438083/neo4j-csv-cypher-import And your file can be local or distant, so it will work on dropbox, if anybody can see the file.logisima

2 Answers

1
votes

Not that mysterious, Neo4j's IMPORT CSV function looks for the specified CSV file in the import directory within your server configuration for that database, as specified at the top of its server configuration file. (IE: dbms.directories.import=import in your neo4j.conf file.)

You should create the import directory in...

"C:\Users\[User Name]\Documents\Neo4j\default.graphdb\"

If you place your CSV file in there, you can specify any sub-directory or just the "file.csv" you want to import with the IMPORT CSV function as below.

LOAD CSV WITH HEADERS FROM "file:///file.csv" AS row RETURN row LIMIT 5

0
votes

Try using:

"file:///C:/path/to/file/file.csv"

Since your file is on your local computer, the third / following the file scheme is not preceded by a host name or address -- but it still needs to be there. Also, file URI path separators should be forward slashes (even on Windows machines).

See the File URI scheme Wikipedia page if you need more information.