Lame-Ov2.0
Lame-Ov2.0

Reputation: 201

SET in combination with LOAD CSV in cypher

I am new to Neo4j/Cypher. I am trying to set properties of a node using various columns of info from my imported CSV file, but I am having trouble. Here are the relevant parts of my attempt:

// Barge, Boat, City, Port.

USING PERIODIC COMMIT
LOAD CSV WITH HEADERS FROM
'file:///test.csv' AS line
WITH line

CREATE (p:port {name: UPPER(line.location_name)})

SET p.year = {line.event_year},
    p.day = {line.event_day},
    p.month = {line.event_month}

But I keep getting an error message that reads:

Invalid input '.': expected an identifier character, whitespace, '}' or            ':' (line 33, column 19 (offset: 871))
"SET p.year = {line.event_year},"
                   ^

And I don't know what to make of it. I know that if I was manually setting the property to a value -- and not having the property set as the value in the specified column of the CSV file -- there wouldn't be an issue. I've also tried enclosing the property value in backticks as opposed to curly brackets.

Upvotes: 0

Views: 179

Answers (1)

William Lyon
William Lyon

Reputation: 8546

Just a syntax issue - you don't need the curly braces:

SET p.year = line.event_year,
    p.day = line.event_day,
    p.month = line.event_month

Curly braces are used for query parameters (or for inlining properties in a node pattern). In this case line is a map variable, not a query parameter.

Upvotes: 2

Related Questions