Cannot merge the following node because of null property value for

Hi Friends,

When trying to import an CSV using the query:

LOAD CSV WITH HEADERS FROM 'file:///nation.csv' AS nation

MERGE (n:NATION {n_nationkey: toInteger(nation.n_nationkey), n_name: nation.n_name, n_regionkey: toInteger(nation.n_regionkey), n_comment: nation.n_comment})

I am receving the following error:

Cannot merge the following node because of null property value for 'n_comment': (:NATION {n_comment: null})

I did modified the query as shown in the guide with :

LOAD CSV WITH HEADERS FROM 'file:///nation.csv' AS row with row where row.n_nationkey is not null

MERGE (n:NATION {n_nationkey: row.n_nationkey})

set n.n_name=row.n_name, n.regionkey=row.n_regionkey, n_comment=row.n_comment

But receiving the following error:

Variable n_comment not defined (line 3, column 55 (offset: 200))
"set n.n_name=row.n_name, n.regionkey=row.n_regionkey, n_comment=row.n_comment"

I have few CSV that i want to import, and the one i am talking about it is in the screenshot attached.

I am not sure what am i doing wrong. Thank you in advance for your help.

Hello @vhronn and welcome to the Neo4j community :slight_smile:

You have a spelling mistake I guess: n_comment=row.n_comment instead of n.comment=row.n_comment (replace the _ by .)

Best regards,
Cobra

1 Like
Try this: use n.n_comment=row.n_comment
1 Like

Thank you. It worked, however there is nothing created and added. Screenshot below. It might be because of a wrong directory?

Run this to see if you are getting any data from .csv file. Also check the column names in the .csv file.

LOAD CSV WITH HEADERS FROM 'file:///nation.csv' AS row with row where row.n_nationkey is not null 
return row  limit 6

Check the column names in the result set.
1 Like