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.

Import CSV With Optional Datetime Property

I'm completely new to Neo4j, so bear with me. I am trying to import a csv file where each row has an optional datetime value (some blank, some not). How could I import this data while applying the datetime() function to the rows where it's not null, and simply not setting that property when it is empty? (I don't want to skip the row, just that property).

1 ACCEPTED SOLUTION

Hello @peter.conrey

You can use the following hack to achieve what you want:

FOREACH (ignore IN CASE WHEN row.datetime IS NULL THEN [] ELSE [1] END | 
SET n.datetime = row.datetime)

where n is the node for which you want to set the optional property.

This will add the property only for those rows where datetime is not blank. Rest of the nodes will remain without the datetime property.

Hope this helps.

View solution in original post

2 REPLIES 2

Hello @peter.conrey

You can use the following hack to achieve what you want:

FOREACH (ignore IN CASE WHEN row.datetime IS NULL THEN [] ELSE [1] END | 
SET n.datetime = row.datetime)

where n is the node for which you want to set the optional property.

This will add the property only for those rows where datetime is not blank. Rest of the nodes will remain without the datetime property.

Hope this helps.

Thank you! That's exactly the solution I was looking for.