Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
02-14-2020 07:23 AM
Neo4j (with Docker) Version: 3.1.7
Operating System: Xubuntu 16.04
API: Python
Created Neo4j Docker with the following:
sudo docker run
--restart=unless-stopped
--memory=9g
--net=dnet01 --ip=1*** 1
--volume=/production/data/neo4j/db:/var/lib/neo4j/data
--volume=/production/analytics/Docker/neo4j/conf:/var/lib/neo4j/conf
--volume=/etc/letsencrypt/neo4j:/var/lib/neo4j/certificates
--volume=/production/analytics/Docker/neo4j/plugins:/var/lib/neo4j/plugins
--volume=/production/analytics/Logs/neo4j:/var/lib/neo4j/logs
--volume=/production/analytics/Temp:/var/lib/neo4j/import
--env=NEO4J_dbms_memory_pagecache_size=8G
--env=NEO4J_dbms_memory_heap_maxSize=8G
--env=NEO4J_dbms_tx_log_rotation_retention_policy="2 days"
--env=NEO4J_dbms_connectors_default_listen_address=0.0.0.0
--env=NEO4J_dbms_connector_http_enabled=true
--ulimit=nofile=40000:40000
--publish=7473:7473 --publish=7474:7474 --publish=7687:7687
--env NEO4J_AUTH=neo4j/
--name=pmirdk-neo4j
-d neo4j:3.1.7
Placed a test_file in location: /production/analytics/Temp/test-file.csv
Then tried to run below code in python:
test_file="test-file.csv"
file_id="file:///"+str(test_file)
with neosession.begin_transaction() as tx:
tx.run("""LOAD CSV WITH HEADERS FROM {csv_file} AS row
MERGE (s:Test {Name: row._Name})
SET s.id = row._id"""
,{'csv_file': file_id}
)
tx.commit
When I run the above script I get the below error:
neo4j.v1.exceptions.CypherError: Couldn't load the external resource at: file:/production/analytics/Temp/test-file.csv
My neo4j conf has the following:
Below is commented out:
##dbms.security.allow_csv_import_from_file_urls=true
Below option in uncommented:
dbms.directories.import=import
Not sure why the file in not being accessed: /production/analytics/Temp/test-file.csv
02-14-2020 08:45 AM
This is not a valid file URL. I think you're looking for:
file:///production/analytics/Temp/test-file.csv
And that must exist in the docker container.
Note that's a TRIPLE slash, and not an error. The first two slashes are about the file:// scheme, and the last slash is the root directory on your machine.
02-17-2020 01:01 AM
Hi David,
I do merge the file:/// to the file name and then pass it to the query.
I also did try with:
tx.run("""LOAD CSV WITH HEADERS FROM 'file:///test_file.csv' AS row
MERGE (s:Test {Name: row._Name})
SET s.id = row._id"""
But i get the same error: " Couldn't load the external resource at: file:/production/analytics/Temp/test_file.csv"
"And that must exist in the docker container." - I didn't quite get this? I am already setting the import directory as: --volume=/production/analytics/Temp:/var/lib/neo4j/import while running my docker.
Is there somewhere else I need to make any change?
02-26-2021 01:31 PM
confused as
file:/production/analytics/Temp/test_file.csv"
but yet
--volume=/production/analytics/Temp:/var/lib/neo4j/import
and Temp
has a trailing :
is that correct? ???
also if the import directory us --volume=/production/analytics/Temp:/var/lib/neo4j/import
and whether there is a :
after Temp or not ??? but if test_file.csv is in this path, i.e. namely /production/analytics/Temp:/var/lib/neo4j/import/test_file.csv then the load csv
should simply reference file:///test_file.csv
03-30-2022 10:49 AM
Was this issue ever resolved? I am still facing the same issue. I have 3 node neo4j cluster and each cluster member is running in a docker constainer in different host.
I have mapped the import folder from the host to the container at /var/lib/neo4j/import
When I run this command:
LOAD CSV FROM 'file:///products.csv' AS line RETURN DISTINCT file() AS path;
I still get this error:
Couldn't load the external resource at: file:/var/lib/neo4j/import/products.csv
12-04-2020 10:42 AM
I am having a very similar issue. I am running a locally deployed Kubernetes Neo4j cluster with 3 cores and 3 replicas. I copied my .csv files to /var/lib/neo4j/import inside of core 0 docker container. Then I go to the CLI and start cypher-shell:
# pwd
/var/lib/neo4j/import
# ls
USAir_edges.csv USAir_nodes.csv
# cypher-shell
Connected to Neo4j 4.2.0 at neo4j://localhost:7687.
Type :help for a list of available commands or :exit to exit the shell.
Note that Cypher queries must end with a semicolon.
@neo4j> load csv with headers from 'file:///USAir_nodes.csv' as row
create (n:Node {id: toInteger(row.id)});
Couldn't load the external resource at: file:/var/lib/neo4j/import/USAir_nodes.csv
I do not quite get why it can't be loaded and why the resource is "external" in this case.. Could you take a look at the issue please?
02-25-2021 09:35 PM
I have the same problem. Have you solved the problem?
10-23-2022 09:39 PM
Using docker, I defined the import volume as:
-v $HOME/neo4j/import:/var/lib/neo4j/import
Then, I copied the files to <container>:/import... i.e.
sudo docker cp myfile.csv neo4j:/import
That works for me.
All the sessions of the conference are now available online