Reputation: 51
Little new to Neo4j so maybe this is a little stupid but I have searched high and low to find and answer
I am trying to import data from a .csv that has spaces in the headers. I can import the file just fine but when I reference the rows in the cypher statement I get an error.
To demonstrate, if I run the following cypher query the 100 rows are displayed / returned just fine
LOAD CSV WITH HEADERS FROM "file:///AppDataOrig.csv" AS row with row limit 100 return row
If I then try the following
LOAD CSV WITH HEADERS FROM "file:///AppDataOrig.csv" AS row with row limit 1
with row.'Device Name' as device
return device
I get the error:
Invalid input ''': expected an identifier, whitespace, a function name or a
property key name (line 2, column 10 (offset: 87))
"with row.'Device Name' as device"
It does not like the quoted Device Name
but if I leave out the quotes it does not like the space
I have seen this done in videos, but don't know where I am going wrong - perhaps this is just not supported any more?
Upvotes: 4
Views: 3087
Reputation: 66999
Use the backtick (`) to quote names containing unusual characters (like non-alphanumeric characters or spaces). For example:
LOAD CSV WITH HEADERS FROM "file:///AppDataOrig.csv" AS row
RETURN row.`Device Name` AS device
LIMIT 1;
Upvotes: 14