Load_csv : no file found

Hello,
what am i doing wrong?
the memgraph is running in the docker, but i’m connecting to the db from the CLI client.

[az@dell5000 airline]$ ls -l ./Environment.csv 
-rw-r--r-- 1 az az 41 Dec 15 18:45 ./Environment.csv
[az@dell5000 airline]$ cat ./Environment.csv 
id, goal,date
1, "Fat goal", 12/12/2022

[az@dell5000 airline]$ mgconsole --host=172.26.0.2 --use-ssl=False --port=7687
mgconsole 1.1
Connected to 'memgraph://172.26.0.2:7687'
Type :help for shell usage
Quit the shell by typing Ctrl-D(eof) or :quit
memgraph> LOAD CSV FROM "Environment.csv" WITH HEADER AS row
       -> CREATE (e:Environment {id: row.id, Goal: row.goal, date: row.date});
Client received exception: CSV file not found: Environment.csv

Answer:
load is done by the DB process. As such the file needs to be in the mg_import directory.

1 Like

You are right that the loading is done by the database process. This means that if Memgraph is running within a Docker container, you would need to copy the files to that container first. You can do that by first finding the id of the Docker container (CONTAINER_ID):

docker ps

And now you can copy the file with the docker cp command:

docker cp ./Environment.csv CONTAINER_ID:/var

But it doesn’t have to be the mg_import directory. For example, you could copy the file to the var directory of the container and call the LOAD CSV query with an absolute path to the CSV file:

LOAD CSV FROM "/var/Environment.csv" WITH HEADER AS row
1 Like

right, agreed. I was thinking more from an architectural standpoint. For the large files, you want a dedicated host volume, so it doesn’t blow the “/” up.