Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
03-09-2021 03:29 PM
Hello there,
I am loading the data from a sample CSV into Employee. The CSV has 2 columns - birthdate and hiredate. The code is like this -
load csv with headers from 'file:///northwind/employees2.csv' as row
merge(c:Country {country : row.country})
merge(e:Employee {
employeeId:toInteger(row.employeeID)
,firstName : row.firstName
,birthDate : date(datetime({epochmillis:apoc.date.parse(row.birthdate, 'ms', 'yyyy-MM-dd')}))
,hireDate : date(datetime({epochmillis:apoc.date.parse(row.hiredate, 'ms', 'yyyy-MM-dd')}))
})
create (e) - [:HAS_COUNTRY {countryName:c.country}] -> (c);
Getting following error -
Cannot construct date time from: NO_VALUE (Failure when processing file '/C:/neo4j423/import/northwind/employees.csv' on line 2.)
I tried with just 1 row in the csv. birthdate and hiredate both are available.
If I try with a hardcoded value like '2001-01-01', the code works just fine.
Any ideas what could be wrong?
Thanks
Manoj Joshi
08-16-2021 11:06 AM
I have the same issue. Did you end up solving it?
It seems that the datetime() function requires a hardcoded timestamp value rather than a variable or alias
08-16-2021 11:38 AM
Please post the date value as in your .csv file so that I can suggest a solution
08-16-2021 12:25 PM
@ameyasoft I'm not sure about OP's value, but mine is 1609283699032, and the query giving me the
Cannot construct date time from: NO_VALUE
error is the one below
match (n:MyNode)
with date(datetime({epochmillis: n.timestamp})) as r
return r
where n.timestamp is the value 1609283699032
08-16-2021 12:58 PM
.csv file stores all values as strings. While importing, one needs to use toInteger function and that stores the property value as integer. Here is the workaround sample:
with '1609283699032' as tme
with date(datetime({epochmillis: toInteger(tme)})) as r
return r
Result: "2020-12-29"
08-16-2021 01:15 PM
@ameyasoft thank you!
For anyone who reads this in the future:
After trying out ameyasoft's solution, I discovered that passing in a string timestamp could also produce this different error: Cannot construct date time from: String("1609283699032")
, which is more informative than the first error I got.
After that, I also realized that my error was coming from me reading in null values for n.timestamp, so I just added a WHERE n.timestamp IS NOT NULL
, and it fixed the problem
All the sessions of the conference are now available online