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.
Related
After running a query and saving the results into a table, I went on exporting its content into a GCS bucket.
When in the table, I clicked Export and the following screen showed up
Because the table was bigger than 1 GB, I've used
bucketname/all_years*
Then, because I wanted it in both CSV and JSON, specified the Export format CSV, started the export and repeated for JSON.
Didn't notice if I got CSV and JSON files inside of the bucket (I deleted it right away due to costs, but my memory tells they weren't .csv / .json already inside of the bucket) and once I downloaded the content from the bucket to my Windows machine, I got a file of type file:
To go around this I had to go to every file properties and add .csv / .json and click OK
Why is that even though i specified the export format as .CSV and .JSON I got a file of type file?
Just setting Export Format controls file format but not file extension - You should explicitly set file extension
So, instead of bucketname/all_years* - you should use bucketname/all_years*.json for example or bucketname/all_years*.csv
I am using Community edition 3.0.5 on Windows 10 . I made multiple efforts to execute a LOAD CSV command before being told that such files cannot reside on an external drive. When I moved the file to users/user/ and tried to execute the LOAD CSV command I got the same message "Couldn't load the external resource at: file:/F:/Neo4j%20DBs/Data.gov%20Consumer%20Complaints/Consumer%20Complaints%20DB/import/Users/CharlieOh/Consumer_Complaints.csv" in spite of the fact the command I entered was
"LOAD CSV WITH HEADERS FROM
'file:///Users/CharlieOh/Consumer_Complaints.csv' AS line
WITH line
LIMIT 1
RETURN line"
I tried to locate the file neo4j.conf and could only find C:\Program Files (x86)\Neo4j Community 3.2.2\Neo4j Community.install4j\i4jparams.conf . I even deleted the old DB and recreated the small amount of data and got the same error, which seems to indicate that the LOAD CSV function is totally useless across all my neo4j databases. BTW the %20 in the file specification was due to suggestions on Stack Overflow as well as using underscores to avoid any use of blank spaces in the file specification. None of it worked and now that I believe that I may have solved the problem by putting the csv file in the user directory, the LOAD CSV function won't let me do it. One last thing, I am following the YouTube video https://www.youtube.com/watch?v=Eh_79goBRUk to learn how to load a csv file into neo4j.
The csv file needs to go in the import directory of the specific database. With Neo4j Desktop this is easy to identify by clicking on the Manage button of the database and then the open folder button. It looks like you've found it.
Once the database import directory is located, you specify it in the LOAD CSV with the statement LOAD CSV WITH HEADERS FROM 'file:///" + FN + "'where FN is your file name, including the csv extension. You do NOT use the full path; that is assumed.
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.
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