I trying to upload CSV to Neo4j Desktop (Version 3.3.5 Enterprise). Here is my code:
LOAD CSV WITH HEADERS FROM "file///:C:/Users/dr-gouda/.Neo4jDesktop/neo4jDatabases/database-22e2ad52-6882-472b-abc6-6c1594e733f2/installation-3.3.5/import/test.csv" as types
create (a1:Type {Label: types.Label, Name: types.Name, Age: types.Age})
I got this message as an error:
Neo.ClientError.Statement.ExternalResourceFailed: Invalid URL 'file///:C:/Users/dr-gouda/.Neo4jDesktop/neo4jDatabases/database-22e2ad52-6882-472b-abc6-6c1594e733f2/installation-3.3.5/import/test.csv': no protocol: file///:C:/Users/dr-gouda/.Neo4jDesktop/neo4jDatabases/database-22e2ad52-6882-472b-abc6-6c1594e733f2/installation-3.3.5/import/test.csv
What is going on and what can I do?
Files for import are relative to the import directory for the db in question (otherwise a user using a load query to supply a file path to a sensitive file, which would be a huge security problem).
Since you already have the file there, use the relative path ... FROM "file:///test.csv" ...
Also, the : was in the wrong place.
Related
I have a huge json file (1 gb) data and I want to insert it into Neo4j database in google cloud platform. I have uploaded my json file in /var/lib/neo4j/import directory and I tried to use the following cypher code to create my nodes in neo4j. Unfortunately I receive the following error.
call apoc.load.json('file:///nov.json') yield value
unwind value as val
merge(a:Article{title:val.title, text:val.text, url:val.url })
Following error
Failed to invoke procedure `apoc.load.json`: Caused by: java.lang.RuntimeException: Can't read url or key file:/var/lib/neo4j/import/nov.json as json: /var/lib/neo4j/import/nov.json (No such file or directory)
I would like to know what is the best way to load this json file into neo4j database.
Once apoc.import.file.enabled=true is enabled, imports should use (file) URLs relative to the dbms.directories.import directory.
I believe the URL should be file://nov.json (and not the absolute path file:///nov.json).
I am facing difficulty in importing a csv file in neo4j. I am working on Windows I have been trying this:
LOAD CSV WITH HEADERS FROM "file:c:/path/to/data.csv" as submissions create (a1:Submission {preview: submissions.preview, secure_media_embed: submissions.secure_media_embed, media: submissions.media, secure_media: submissions.secure_media, media_embed: submissions.media_embed})
Getting error:
URI is not hierarchical
Any suggestion on what I am doing wrong here, I have been following blogs and all suggests this
Edit the neo4j conf file (/etc/neo4j/neo4j.conf)
change the below line
dbms.directories.import=import
to
dbms.directories.import=/home/suyati/Downloads/
for loading a file from downloads.
In neo4j browser:
load csv with headers from "file:///1.csv" as row
(Your file should be there like /home/suyati/Downloads/1.csv)
Its will works fine.
I am trying to load data into neo4j using a local csv on my system:
USING PERIODIC COMMIT
LOAD CSV WITH HEADERS FROM "file:/Users/jlujan/Desktop/northwind/customers.csv" AS row
CREATE (:Customer {CustomerID: row.CustomerID, CompanyName: row.CompanyName,
ContactName: row.ContactName, ContactTitle: row.ContactTitle,
Address: row.Address, City: row.City, Region: row.Region, PostalCode: row.PostalCode, Country: row.Country, Phone: row.Phone, Fax: row.Fax});
Every time I get this error: Couldn't load the external resource at: file:/var/lib/neo4j/import/Users/jlujan/Desktop/northwind/customers.csv
I think it's a URL issue, but I'm not exactly sure what. Please help!
Looks like you're using Neo4j 3?
You'll find a setting in neo4j.conf like this
# This setting constrains all `LOAD CSV` import files to be under the `import` directory. Remove or uncomment it to
# allow files to be loaded from anywhere in filesystem; this introduces possible security problems. See the `LOAD CSV`
# section of the manual for details.
dbms.directories.import=import
If you remove this/comment it, Neo4j should allow loading files from anywhere in the system
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;
LOAD CSV WITH HEADERS FROM "file:/path/to/file/file.csv"
as row
CREATE (m:movie {name:row.movie})
But it gave syntax errors. I found out I could correct it by using double \ and add "file:";
LOAD CSV WITH HEADERS FROM "file://C:\\path\\to\\file\\file.csv"
as row
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?
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
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.
Trying CSV import to Neo4j - doesn't seem to be working.
I'm loading a local file using the syntax:
LOAD CSV WITH HEADERS FROM "file:///location/local/my.csv" AS csvDoc
Am wondering if there's something wrong with my CSV file, or if there's some syntax problem here.
If you didn't read the title, the error is:
Couldn't load the external resource at: file:/location/local/my.csv
[Neo.TransientError.Statement.ExternalResourceFailure]
Neo4j seems to need a full path spec to get a file on the local system.
On linux or mac try
LOAD CSV FROM "file:/Users/you/location/local/my.csv"
On windows try
LOAD CSV FROM "file://c:/location/local/my.csv"
.
In the browser interface (Neo4j 3.0.3, MacOS 10.11) it looks like Neo4j prefixes your file path with $path_to_graph_database/import. So you could move your files there. If you are using a command line tool, then see this SO question.
Easy solution:
Once you choose your database location (in my case ReactomeGraphDB60)...
here I placed my ddbb
...go to that folder, and create inside a folder called "import".
Later in the cypher query write (as an example):
LOAD CSV WITH HEADERS FROM "file:///ILClasiffStruct.csv" AS row
CREATE (n:Interleukines)
SET n = row