Neo.ClientError.Statement.ExternalResourceFailed

Neo.ClientError.Statement.ExternalResourceFailed

load csv with headers from 'file:///C:/Users/user/Desktop/Neo4J'
as row 
Create (:State_Code {state_cd:row.st_cd})

我试过这段代码,它抛出一个错误:

Neo.ClientError.Statement.ExternalResourceFailed: Couldn't load the external resource at: file:/C:/Users/ssarse/Desktop/Neo4J

谁能帮我解决这个问题?

默认情况下,Neo4j 不允许从文件 URLs 加载数据。如果允许,它只从导入目录读取文件。

如果你想从其他目录加载文件,你必须在 neo4j.conf

中允许

您可以轻松配置:

  1. 为您的 Neo4j 安装找到 neo4j.conf 文件。 Read here about file locations.

  2. 注释这一行(在开头添加#):

    dbms.directories.import=import
    
  3. 取消注释此行以允许从文件 URL:

    导入 CSV
    #dbms.security.allow_csv_import_from_file_urls=true
    
  4. 重启 Neo4j

确保文件是干净的并且没有使用错误的扩展名;因为根据我的经验,不这样做会导致它无法导入。