首页 > 解决方案 > 将 CSV 加载到 Neo4j 时出错

问题描述

我正在尝试将本地存储的 .csv 文件加载到 Neo4j 中。我也尝试将它发布到谷歌表格,但这并没有让我更接近我需要的东西。

我已将 csv 存储在我的导入文件夹中,文件路径为:

"C:\Users\FJ1993.Neo4jDesktop\neo4jDatabases\database-325e28a1-76ac-4268-820e-844bda8d4812\installation-3.4.0\import\GTD sample_location_target_attacker.csv

在尝试加载到 Neo4j 时,我根据我看过的教程和 Neo4j 文档尝试了两种方法:

1)

从 "file://C:/Users/FJ1993/.Neo4jDesktop\neo4jDatabases/database-325e28a1-76ac-4268-820e-844bda8d4812\installation-3.4.0/import/GTD" sample_location_target_attacker.csv 中加载带有标题的 CSV

错误是

Neo.ClientError.Statement.SyntaxError:无效输入'i':预期'\'、'''、'"'、'b'、'f'、'n'、'r'、't'、UTF16 或 UTF32 (第 1 行,第 127 列(偏移量:126))“从文件中加载带有标题的 CSV://C:/Users/FJ1993/.Neo4jDesktop\neo4jDatabases/database-325e28a1-76ac-4268-820e-844bda8d4812\installation-3.4 .0/import/GTD" sample_location_target_attacker.csv WITH line"

2)

从“file://C:/Users/FJ1993/.Neo4jDesktop\neo4jDatabases/database-325e28a1-76ac-4268-820e-844bda8d4812\installation-3.4.0/import/GTD sample_location_target_attacker.csv”作为 csvDoc 加载带有标题的 CSV

错误是

Neo.ClientError.Statement.SyntaxError:无效输入'i':预期'\'、'''、'"'、'b'、'f'、'n'、'r'、't'、UTF16 或 UTF32 (第 1 行,第 127 列(偏移量:126))“从文件中加载带有标题的 CSV://C:/Users/FJ1993/.Neo4jDesktop\neo4jDatabases/database-325e28a1-76ac-4268-820e-844bda8d4812\installation-3.4 .0/import/GTD sample_location_target_attacker.csv"AS csvDoc"

3)我还尝试从我发布的 Google 表格上传。

链接是https://docs.google.com/spreadsheets/d/e/2PACX-1vSOpbMUwFnf7gMYm7JaB3gzWGV7or0qU7cLIsjwApq4sH63v88O1fd0RrmbxvBlVWMfVASh0sw9zJX_/pubhtml

我的密码是:

从“ https://docs.google.com/spreadsheets/d/e/2PACX-1vSOpbMUwFnf7gMYm7JaB3gzWGV7or0qU7cLIsjwApq4sH63v88O1fd0RrmbxvBlVWMfVASh0sw9zJX_/pubhtml ”中加载带有标题的 CSV作为行返回 10

错误消息是:

Neo.DatabaseError.General.UnknownError:在https://docs.google.com/spreadsheets/d/e/2PACX-1vSOpbMUwFnf7gMYm7JaB3gzWGV7or0qU7cLIsjwApq4sH63v88O1fd0RrmbxvBlVWMfVASh0sw9zJX_/pubhtml @ position 4388 - 有一个字段似乎以引号开头是结束引号之后该字段中的字符。这是不支持的。这是我读到的:'docs-smheo":'

有谁知道如何将 csv 文件导入 Neo4j?我不够熟练,无法写入命令行,完全依赖 GUI。

谢谢

标签: csvneo4jsyntax

解决方案


Looks like you had a quotation mark in the wrong place after "import/GTD", a missing forward slash after file and you shouldn't specify the full path.

You also have a mixture of forward and backward slashes in your file path. Use forward slashes, but since you don't specify the full path, this is only useful if you have folders within your import folder.

I recommend you remove the space after GTD, just to be safe.

Try this and I hope it helps:

LOAD CSV WITH HEADERS FROM "file:///GTD sample_location_target_attacker.csv" WITH line

Original

LOAD CSV WITH HEADERS FROM "file://C:/Users/FJ1993/.Neo4jDesktop\neo4jDatabases/database-325e28a1-76ac-4268-820e-844bda8d4812\installation-3.4.0/import/GTD" sample_location_target_attacker.csv WITH line

推荐阅读