尝试获取.csv列时遇到错误 [英] Facing an error while trying to get a .csv column

查看:173
本文介绍了尝试获取.csv列时遇到错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在Neo4j中显示.csv文件的一列。 .csv文件的内容如下:

I'm trying to display one column of a .csv file in Neo4j. Here in the content of .csv file:

site,IP
ex1.com,10.10.10.10
ex2.com,11.0.0.0

我使用以下查询:

LOAD CSV WITH HEADERS FROM 'file:///file.csv' AS row
WITH row[1] AS ip
RETURN ip
LIMIT 3

但我收到此错误:

Expected Long(1) to be a org.neo4j.values.storable.TextValue, but it was a org.neo4j.values.storable.LongValue

出什么问题了?

推荐答案

由于您指定了 WITH HEADERS 选项,因此应使用适当的标题名称而不是使用索引来访问文件的数据字段(例如, row [1] )。 索引只会给您奇怪的结果或错误,因为该软件会尝试将标头行与其他任何行一样对待。

Since you specified the WITH HEADERS option, you should access the file's data fields using the appropriate header names instead of using indexing (e.g., row[1]). Indexing would just give you strange results or errors because the software would try to treat the header row like any other row.

例如,查询应该正常工作:

For example, this query should work just fine:

LOAD CSV WITH HEADERS FROM 'file:///file.csv' AS row
RETURN row.IP AS ip
LIMIT 3

这篇关于尝试获取.csv列时遇到错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆