2
votes

I have a fresh install of Neo4j 2.1.4 open source on a corporate cloud server running Ubuntu 14.04. I am importing a CSV file into the database. The path to my file is '/home/username/data-neo4j/node.csv'

Below is my command, which I run from the Neo4j command line tool neo4j-shell:

LOAD CSV WITH HEADERS FROM "file:///home/username/data-neo4j/node.csv" AS line CREATE (:Node { nid: toInt(line.nid), title: line.title, type: line.type, url: line.url});

This returns:

LoadExternalResourceException: Couldn't load the external resource at: file:/home/user/data-neo4j/node.csv

This looks like a message saying it can't find the file. However, the file is in place. I even tried changing the permissions on the file to be 755.

I have a separate instance of Neo4j on my local machine (OSX with Neo4j 2.1.2 Enterprise). The command is successful on my local machine, given that I switch the path to match.

One thing I notice when I run neo4j-shell, I get NOTE: Remote Neo4j graph database service 'shell' at port 1337. I have opened this port and my command still returns the same error message.

I also read through this link - but their problem was that they had not uploaded their file. My file is in place.

neo4j LOAD CSV returns Couldn't Load external resource

2

2 Answers

5
votes

sheldonkreger, your co-worker is right. Thanks to him.

I solved it doing the same, but you actually don't need to place the file in a location where neo4j user has permissions, as suggested by him, for example /var/log/neo4j or /var/lib/neo4j.

Instead, just go to the neo4j directories mentioned above and see the file permissions over there, and provide the same permissions to your csv file or whichever file you are trying to import.

For example, for my system the file permissions in neo4j folder was like this:

ls -la
total 208
drwxr-xr-x  4 neo4j adm    4096 Feb  4 10:35 .
drwxr-xr-x 87 root  root   4096 Feb 11 22:21 ..
drwxr-xr-x  3 neo4j adm    4096 Feb  4 10:35 bin
-rw-r--r--  1 neo4j adm   61164 Jan 29 22:32 CHANGES.txt
lrwxrwxrwx  1 neo4j adm      10 Sep 30 12:07 conf -> /etc/neo4j
drwxr-xr-x  4 neo4j adm    4096 Mar 13 13:25 data
lrwxrwxrwx  1 neo4j adm      20 Sep 30 12:07 lib -> /usr/share/neo4j/lib
-rw-r--r--  1 neo4j adm  125517 Jan 29 22:32 LICENSES.txt
lrwxrwxrwx  1 neo4j adm      24 Sep 30 12:07 plugins -> /usr/share/neo4j/plugins
-rw-r--r--  1 neo4j adm    1568 Jan 29 22:32 README.txt
lrwxrwxrwx  1 neo4j adm      23 Sep 30 12:07 system -> /usr/share/neo4j/system
-rw-r--r--  1 neo4j adm    4018 Jan 29 22:30 UPGRADE.txt

So I did the same to my file and neo4j was successfully able to run the import command.

I did this:

sudo chown neo4j:adm <csv file location>
2
votes

A co-worker helped me debug this.

The problem was a permission. In Linux, neo4j has its own user 'neo4j'. That user did not have permissions to access the data at /home/myuser/data-neo4j/node.csv

We moved the data to a folder where the neo4j user has permissions and adjusted the path in the query.

For future reference, the log for Neo4j can provide additional info, an in Linux, is found at /var/log/neo4j