Neo4j Importing local CSV File

情到浓时终转凉″ 提交于 2019-12-21 09:19:38

问题


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"


回答1:


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.




回答2:


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/




回答3:


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




回答4:


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!



来源:https://stackoverflow.com/questions/37299077/neo4j-importing-local-csv-file

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!