I'm trying to import a local csv file but I have got InvalidSyntax Error.
LOAD CSV WITH HEADERS FROM file:C:/csv/user.csv
Invalid input '/' (line 1, column 35 (offset: 34)) "LOAD CSV WITH HEADERS FROM file:C:/csv/user.csv"
I'm trying to import a local csv file but I have got InvalidSyntax Error.
LOAD CSV WITH HEADERS FROM file:C:/csv/user.csv
Invalid input '/' (line 1, column 35 (offset: 34)) "LOAD CSV WITH HEADERS FROM file:C:/csv/user.csv"
You need to put the filename in quotes, and add a few more slashes:
LOAD CSV WITH HEADERS FROM "file:///C:/csv/user.csv"
Full documentation here.
The command below will return the first 5 lines of your CSV file:
LOAD CSV WITH HEADERS FROM "file:///<PATH_TO_YOUR_CSV_FILE>" AS line WITH line RETURN line LIMIT 5;
But you'll have to follow some steps to align with Neo4J security restrictions.
1) Find the conf folder in the neo4j server folder. Open the neo4j.conf with a text editor.
2) Uncomment the line containing:
#dbms.security.allow_csv_import_from_file_urls=true
To uncomment it, just remove #. It should be like this:
dbms.security.allow_csv_import_from_file_urls=true
3) Comment this line below:
dbms.directories.import=import
To comment it, add #. It should be like this:
#dbms.directories.import=import
Further on importing from CSV in neo4j documentation here: https://neo4j.com/blog/importing-data-neo4j-via-csv/
LOAD CSV WITH HEADERS FROM "file:C:/path/location/filename.csv" AS row
Found that these query asks Neo4j to look in a specific location C:\Users\*******\.Neo4jDesktop\neo4jDatabases\database-2b9d81ff-1976-427e-ba98-4f3191c3ef62\installation-3.4.9\import
placing your csv here and using the query
LOAD CSV WITH HEADERS FROM "file:///testData2.csv" AS line
solved the issue for me
or you can change the settings by making changes here
dbms.directories.import=import
NB: I am using windows 10 , neo4j-desktop-offline-1.1.12
I had the same problem (in Windows 10) and I realized that I was just trying to load the CSV file without saying to it to return something. For me it worked pretty well like this:
LOAD CSV WITH HEADERS FROM "file:///C:all_data.csv" AS line
RETURN line
Note: Do not forget to place the CSV file that you want to import on the neo4j import file!