0

我正在阅读 [将 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)

我收到以下错误消息:

> > 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"
> 
4

1 回答 1

0

要熟悉 RNeo4j 包,您应该查看RNeo4j GitHub 存储库中的 README和 参考手册

您应该将查询放在多行字符串中并使用该cypher函数。请注意,我在 Cypher 查询中将引号更改为撇号 ( ')。

我还删除了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)

确保提供 CSV 文件的绝对路径,如Neo4j CSV Import Guide中所示。

于 2016-11-17T03:50:28.057 回答