I was reading [importing CSV Data into Neo4j][1] and I tried to execute
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 .
You should put your query in a multiline string and use the cypher
function. Note that I changed the quotes to apostrophes ( '
) in the Cypher query.
I also removed the import for the curl
library as RNeo4j
imports it transitively.
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 .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.