Facing an error while trying to get a .csv column

陌路散爱 提交于 2020-04-17 22:45:00

问题


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

I use this query:

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

but I get this error:

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

What's wrong?


回答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


来源:https://stackoverflow.com/questions/60129695/facing-an-error-while-trying-to-get-a-csv-column

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!