cancel
Showing results for 
Search instead for 
Did you mean: 

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

alexandra
Node Link

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

alexandra
Node Link

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.

Nodes 2022
Nodes
NODES 2022, Neo4j Online Education Summit

On November 16 and 17 for 24 hours across all timezones, you’ll learn about best practices for beginners and experts alike.