我已经查看了有关此主题的所有其他问题,所有答案(即使是已批准的答案)要么不完整,要么错误。所以,我提供了具体的例子,希望得到一个明确的解释。
我在 neo4j.conf 中尝试了以下设置,并且所有设置似乎都以相同的方式处理:
dbms.directories.import=d:\\import\\
dbms.directories.import=d:/import/
dbms.directories.import=d:/import
在浏览器交互 session 中使用以下命令,结果在每个版本命令上方的注释中
// URI is not hierarchical
LOAD CSV WITH HEADERS FROM "file:Endpoint.csv" AS row WITH row LIMIT 4 RETURN row
// Invalid input '/', makes sense but violates "correct" syntax seen online
LOAD CSV WITH HEADERS FROM file:/d:Endpoint.csv AS row WITH row LIMIT 4 RETURN row
LOAD CSV WITH HEADERS FROM file://d:/import/Endpoint.csv AS row WITH row LIMIT 4 RETURN row
LOAD CSV WITH HEADERS FROM file:///d:/import/Endpoint.csv AS row WITH row LIMIT 4 RETURN row
// works, but the drive letter used is completely ignored
LOAD CSV WITH HEADERS FROM "file:/d:Endpoint.csv" AS row WITH row LIMIT 4 RETURN row
// works
LOAD CSV WITH HEADERS FROM "file:/Endpoint.csv" AS row WITH row LIMIT 4 RETURN row
LOAD CSV WITH HEADERS FROM "file:///Endpoint.csv" AS row WITH row LIMIT 4 RETURN row
// Cannot load from URL 'file://Endpoint.csv': file URL may not contain an authority section (i.e. it should be 'file:///')
LOAD CSV WITH HEADERS FROM "file://Endpoint.csv" AS row WITH row LIMIT 4 RETURN row
// URI is not hierarchical
LOAD CSV WITH HEADERS FROM "file:d:/import/Endpoint.csv" AS row WITH row LIMIT 4 RETURN row
LOAD CSV WITH HEADERS FROM "file:d:\\import\\Endpoint.csv" AS row WITH row LIMIT 4 RETURN row
// Couldn't load the external resource at: file:/d:/import/import/Endpoint.csv
LOAD CSV WITH HEADERS FROM "file:///d:/import/Endpoint.csv" AS row WITH row LIMIT 4 RETURN row
LOAD CSV WITH HEADERS FROM "file:///d:\\import\\Endpoint.csv" AS row WITH row LIMIT 4 RETURN row
最佳答案
这应该有效:
dbms.directories.import=d:/import
LOAD CSV WITH HEADERS FROM "file:///Endpoint.csv" AS row WITH row LIMIT 4 RETURN row
它将查找与配置的导入目录相关的文件。
如果您删除(注释掉)配置选项,您也可以提供绝对路径。
LOAD CSV WITH HEADERS FROM "file:///d:/import/Endpoint.csv" AS row WITH row LIMIT 4 RETURN row
关于csv - Windows上的neo4j如何在交互式浏览器 session 中解析cypher load csv中的文件名路径?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/37200088/