简体   繁体   English

Neo4j CSV 导入类型错误

[英]Neo4j CSV Import Type Error

I'm trying to import a CSV file into Neo4j (Community Edition V 2.3.2).我正在尝试将 CSV 文件导入 Neo4j(社区版 V 2.3.2)。 The CSV is structured like this: CSV 的结构如下:

id,title,value,updated
123456,"title 1",10,20160407
123457,"title 2",11,20160405

The CSV path is set within the Neo4j properties file. CSV 路径在 Neo4j 属性文件中设置。

When I use the following import statement当我使用以下导入语句时

LOAD CSV WITH HEADERS FROM   
'file:///test.csv' AS line
CREATE (:Title_Node { title: line[1], identifier: toInt(line[0]), value: line[3]})

I receive the following error message:我收到以下错误消息:

WARNING: Expected 1 to be a java.lang.String, but it was a java.lang.Long警告:预期 1 是一个 java.lang.String,但它是一个 java.lang.Long

When I just query the test.csv file with当我只查询 test.csv 文件时

LOAD CSV WITH HEADERS FROM 'file:///test.csv'
AS line
RETURN line.title, line.id, line.value;

Cypher can access the data without any problem. Cypher 可以毫无问题地访问数据。

+------------------------------------+
| line.title | line.id  | line.value |
+------------------------------------+
| "title 1"  | "123456" | "10"       |
| "title 2"  | "123457" | "11"       |
+------------------------------------+

The effect occurs in the browser as well as in the shell.效果发生在浏览器和外壳中。

I found the following question at Having `Neo.ClientError.Statement.InvalidType` in Neo4j and tried the hints mentioned in the Neo4j Link posted in this answer, but with little success.在 Neo4j 中的“Neo.ClientError.Statement.InvalidType”中发现了以下问题,并尝试了本答案中发布的 Neo4j 链接中提到的提示,但收效甚微。 The CSV file itself seems to be ok by structure (UTF8, no hidden entries etc.). CSV 文件本身的结构似乎没问题(UTF8,没有隐藏条目等)。

Every help in solving this is greatly appreciated.非常感谢解决这个问题的每一个帮助。

Best最好的事物

Krid克里德

You're supplying the fields for the line header, so use them in the import -您正在为行标题提供字段,因此请在导入中使用它们 -

LOAD CSV WITH HEADERS FROM   
'file:///test.csv' AS line
CREATE (:Title_Node { title: line.title, identifier: line.id, value: line.value})

This is a classic example of an error message which is entirely correct, but not very helpful!这是一个错误消息的经典示例,它完全正确,但不是很有帮助!

You can supply literals to line indexes if you prefer-如果您愿意,您可以为行索引提供文字 -

LOAD CSV WITH HEADERS FROM   
'file:///test.csv' AS line
CREATE (:Title_Node { title: line['title'], identifier: line['id'], value: line['value']})

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM