简体   繁体   English

Neo4j:错误:R标记中的“ LOAD CSV”中出现意外符号

[英]Neo4j: Error: unexpected symbol in “LOAD CSV” in R markdown

I was reading [importing CSV Data into Neo4j][1] and I tried to execute 我正在阅读[将CSV数据导入Neo4j] [1],并尝试执行

library("RNeo4j")
library("curl")

graph <- startGraph("http://localhost:7474/db/data", username = "neo4j", password = "")
clear(graph, input = F)

LOAD CSV WITH HEADERS FROM "file:///data//airlines.csv" AS row
CREATE (n:airlines)
SET n = row,
  n.carrier = toFloat(row.carrier),
  n.name = toFloat(row.name)

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

> > LOAD CSV WITH HEADERS FROM "file:///data//airlines.csv" AS row
Error: unexpected symbol in "LOAD CSV"
> CREATE (n:airlines)
Error: could not find function "CREATE"
> SET n = row,
Error: unexpected symbol in "SET n"
>   n.carrier = toFloat(row.carrier),
Error: unexpected ',' in "  n.carrier = toFloat(row.carrier),"
>   n.name = toFloat(row.name)
Error: could not find function "toFloat"
> 

To get familiar with the RNeo4j package, you should check the README in the RNeo4j GitHub repository and the reference manual . 要熟悉RNeo4j软件包,您应该检查RNeo4j GitHub存储库中的自述文件和参考手册

You should put your query in a multiline string and use the cypher function. 您应该将查询放入多行字符串中,并使用cypher函数。 Note that I changed the quotes to apostrophes ( ' ) in the Cypher query. 请注意,我在Cypher查询中将引号更改为撇号( ' )。

I also removed the import for the curl library as RNeo4j imports it transitively. 我还删除了curl库的导入,因为RNeo4j过渡地导入了它。

library("RNeo4j")

graph = startGraph("http://localhost:7474/db/data", username = "neo4j", password = "")
clear(graph, input = F)

query = "
LOAD CSV WITH HEADERS FROM 'file:///data//airlines.csv' AS row
CREATE (n:airlines)
SET n = row,
  n.carrier = toFloat(row.carrier),
  n.name = toFloat(row.name)
"
cypher(graph, query)

Make sure that you provide an absolute path to the CSV file as shown in the Neo4j CSV Import Guide . 确保提供《 Neo4j CSV导入指南》中所示的CSV文件的绝对路径。

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

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