Load CSV doesn't work

Hi,

I need your help: the code doesn't create any relationships:

LOAD CSV WITH HEADERS FROM("file:///test.csv") AS row
MATCH (p1:City {DS:row.from}), (p2:City {DS:row.to})
CREATE (p1)-[:NB]->(p2);

The nodes:

CREATE (a:City {DS: 'AAA'})
CREATE (b:City {DS: 'BBB'})
CREATE (c:City {DS: 'CCC'})
CREATE (d:City {DS: 'DDD'})

The csv file

test.csv

from, to
"AAA","BBB"
"CCC","DDD"

Thanks a lot in advance,

Michel

You saved my day ....

Check the csv header. There is a space before 'to'.

Looks like csv header column has a space before 'to'. You can remove the space before 'to' or use backtick.

MATCH (p1:City {DS:row.from}), (p2:City {DS:row.`` to` `})

CREATE (p1)-[:NB]->(p2)

Above Cypher created the relationships.