Reputation: 3
I am new to cypher and I am trying to import data from CSV file with constraints in cypher, and I get the following error message
Neo.ClientError.Statement.SyntaxError: Invalid input 'L': expected whitespace, comment, ';' or end of input (line 3, column 1 (offset: 54)) "LOAD CSV WITH HEADERS FROM 'file:///routes.csv' AS line"
I tried it without the constraint statement and it works fine, the error appears when I use create constraint
CREATE CONSTRAINT ON (x:Route) ASSERT x.id IS UNIQUE
LOAD CSV WITH HEADERS FROM 'file:///routes.csv' AS line
CREATE (r:Route {id:line.route_id, name:line.route_short_name, fare: TOINT(line.route_fare), url:line.URL})
RETURN r
Upvotes: 0
Views: 376
Reputation: 4052
You need to separate multiple statements in the query with a semicolon(;
).
In your query add a semicolon after first statement(i.e. after UNIQUE
).
CREATE CONSTRAINT ON (x:Route) ASSERT x.id IS UNIQUE;
LOAD CSV WITH HEADERS FROM 'file:///routes.csv' AS line
CREATE (r:Route {id:line.route_id, name:line.route_short_name, fare: TOINT(line.route_fare), url:line.URL})
RETURN r
By default, you can run single statement queries in Neo4j browser. Your query is two statement query so you need to Enable multi-statement query editor in the Neo4j browser settings.
Refer the following screenshot:
Upvotes: 0