cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Loading CSV file with multiple words in column names

Hi,

I am trying to read my CSV file which has spaces in column name: Column A = 'Source Variable'
When I am trying to read this, it gives me an error:

Neo.ClientError.Statement.SyntaxError: Invalid input 'V': expected whitespace, comment, '(', '.', node labels, '[', "=~", IN, STARTS, ENDS, CONTAINS, IS, '^', '*', '/', '%', '+', '-', '=', "<>", "!=", '<', '>', "<=", ">=", AND, XOR, OR, LOAD CSV, FROM, INTO, START, MATCH, UNWIND, MERGE, CREATE GRAPH >>, CREATE >> GRAPH, CREATE GRAPH, CREATE, SET, DELETE GRAPHS, DELETE, REMOVE, FOREACH, WITH, CALL, PERSIST, RELOCATE, RETURN, SNAPSHOT, UNION, ';' or end of input (line 4, column 23 (offset: 99)) "WHERE NOT line.Source Variable IS NULL and NOT line.SourceFile is NULL" ^

My code:

LOAD CSV WITH HEADERS FROM "file:///Matrix.csv" AS line WITH line

WITH line
WHERE NOT line.Source Variable IS NULL and NOT line.SourceFile is NULL
MERGE (a: Studytest {name: line.Studytest, type: 'Study'})
//CREATE (domain: Domain {name: line.Domain})
mergE (b: Domaintest {name: line.Domaintest, type: 'Domain', domain_identifier: line.Studytest + line.Domaintest})

Merge (c: SourceFile {name: line.SourceFile,type: 'Source_File', file_identifier: line.Studytest + line.Domaintest + line.SourceFile})

Merge (d: SourceVariable {name: line.Source Variable,type: 'Source_Variable', field_identifier: line.Studytest + line.Domaintest + line.SourceFile + line.Source Variable})

MERGE (d)-[z:Part_of]->(c)

MERGE (c)-[q:Part_of]->(b)

MERGE (b)-[p:Part_of]->(a)

RETURN a;

1 ACCEPTED SOLUTION

you need to use back ticks for quoting, so

line.`Source Variable`

View solution in original post

4 REPLIES 4

you need to use back ticks for quoting, so

line.`Source Variable`

Hi,

I tried that. I got the below error:

Neo.ClientError.Statement.SyntaxError: Invalid input ''': expected an identifier, whitespace, a function name or a property key name (line 4, column 16 (offset: 92))
"WHERE NOT line.'Source Variable' IS NULL and NOT line.SourceFile is NULL"

Your example is using single quote characters: '. This is not the same as backticks (on a US keyboard, shares the same key as the tilde ~ symbol, and is next to the 1 key): `

Thank you!

Its resolved now