Cypher Neo4j Couldn't load the external resource

前端 未结 15 1715
谎友^
谎友^ 2021-02-07 05:09

In a Windows environment, I\'m trying to load a .csv file with statement:

LOAD CSV WITH HEADERS FROM \"file:///E:/Neo4j/customers.csv\" AS row

15条回答
  •  别那么骄傲
    2021-02-07 05:38

    Neo4j version is 3.1.1, OS is win10.

    For me, LOAD CSV would read from Neo4j_Database_Location/testDB/import/artists.csv.

    At first, I put csv file on the path F:\code\java\helloworld\artists.csv, and my cypher sentence is

    LOAD CSV FROM 'file:///F:\\code\\java\\helloworld\\artists.csv' AS line  
    CREATE(:Artist {name:line[1],year:toInt(line[2])})
    

    Then I get the error message returned as follows:

    Couldn't load the external resource at: file:/D:/Neo4j/db/testDB/import/code/java/helloworld/artists.csv
    

    It means neo4j itself concat the file path. "D:/Neo4j/db/testDB/import/" is the Neo4j database location, and the "code/java/helloworld/artists.csv" is the csv file location.

    For example, I install Neo4j on the path D:\Neo4j\Neo4j CE 3.1.1, and database loaction is D:\Neo4j\db. I put the CSV file on the path D:\Neo4j\db\testDB\import\artist.csv. If you don't have the file folder "import" on the path, you should creat it by yourself and put your file in the folder "import".

    Then, put your csv file in the path, and input cyper sentence:

    LOAD CSV from 'file:///artist.csv' as LINE
    CREATE(:Artist {name:line[1],year:toInt(line[2])})
    

    In a word, once you put the CSV file in the right path, the problem can be solved.

    Related explaination in the LOAD CSV developer-manal

    If dbms.directories.import is set to the default value import, using the above URLs in LOAD CSV would read from /import/myfile.csv and import/myproject/myfile.csv respectively. If it is set to /data/csv, using the above URLs in LOAD CSV would read from /data/csv/myfile.csv and /data/csv/myproject/myfile.csv respectively.

提交回复
热议问题