Neo4j: Error: unexpected symbol in "LOAD CSV" in R markdown
Neo4j: Error: unexpected symbol in "LOAD CSV" in R markdown
我正在阅读[将 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"
>
要熟悉 RNeo4j 包,您应该查看 RNeo4j GitHub repository 和 中的自述文件
参考手册.
您应该将查询放在多行字符串中并使用 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 中所示。
我正在阅读[将 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"
>
要熟悉 RNeo4j 包,您应该查看 RNeo4j GitHub repository 和 中的自述文件 参考手册.
您应该将查询放在多行字符串中并使用 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 中所示。