1

I have a problem while importing .csv file to Neo4j. My neo4j is on docker, when trying to import the csv using express, I get an error: Neo4jError: Couldn't load the external resource at: file:/organizations.csv

I followed this: Neo4j LOAD CSV Error: unknown protocol: c, so I changed my neo4j.conf file, but it didn't resolve my problem, I still get the error. The path is 100% fine, because my .js file is where the .csv file is.

LOAD CSV FROM 'file:///organizacje.csv' AS line
MERGE (o: Organization {organizationNr: toInteger(line[0]),name: line[1]})
RETURN o

What is wrong here?

crazyfrog
  • 197
  • 1
  • 3
  • 11
  • Mount the import folder and attach it to the docker instance, here is example with docker compose: https://github.com/tomasonjo/grand-sigmaJS/blob/main/docker-compose.yml – Tomaž Bratanič Dec 03 '21 at 13:17

1 Answers1

0

By default, importing csv files into neo4j requires the files to be located on this configuration setting found in the local disk (in your DOCKER)

 dbms.directories.import=<NEO4J_HOME>/import/

If you cannot put the file in that local disk, I recommend you to put it in amazon web service or google cloud or microsoft azure. Then use http to access your csv. See example in link below.

 https://neo4j.com/docs/cypher-manual/current/clauses/load-csv/#load-csv-import-data-from-a-remote-csv-file

Example:

 LOAD CSV FROM 'http://<aws S3 dir>/organizacje.csv' AS line
 MERGE (o: Organization {organizationNr: toInteger(line[0]),name: line[1]})
 RETURN o
jose_bacoy
  • 12,227
  • 1
  • 20
  • 38
  • I followed the link I mentioned, so I commented directories.import and made allow url to true. So anyway the only solution is to put it on some cloud? – crazyfrog Dec 03 '21 at 13:33
  • If you can put the file on the disk(docker) set the config to neo4j_home/import and put the file in there. If you cannot put the file on the docker, put it in the cloud and use http to access it. If the file doesnt need to be secured, you can also put it via public ftp and access it there. There are many options. – jose_bacoy Dec 03 '21 at 13:43
  • So the docker doesnt have access to local files and that’s why I experience such a problem? – crazyfrog Dec 03 '21 at 13:56