0

Here's a sample date. I am having this error in mongoimport:

Failed: type coercion failure in document #0 for column 'createDate', could not parse token 'Tue Oct 26 2021 17:00:32 GMT+0800 (Singapore Standard Time)' to type date

I have this string in my .csv file 'Wed Aug 03 2022 14:55:06 GMT+0800 (Singapore Standard Time)' that I need to import in db in this date format >> 2022-08-03T06:55:06.410+00:00

Used this to change the .csv file header

$ sed -i '1s/.*/id.string(), createDate.date(2006-01-02 15:04:05), fullName.string()/' test.csv

And then mongoimport,

mongoimport --uri "mongodb://localhost:27017/" --db testDB --collection testColl --type csv --columnsHaveTypes --file test.csv --headerline

mongoimport could not parse this 'Wed Aug 03 2022 14:55:06 GMT+0800 (Singapore Standard Time)'. Tried changing the dates in file to this format just to check 2020-09-08T09:41:19.693+03:00 and header to createDate.date(2006-01-02) Still could not parse the date in csv

Failed: type coercion failure in document #0 for column 'createDate', could not parse token '2020-09-08T09:41:19.693+03:00' to type date

How to do this? This is the type of date string 'Wed Aug 03 2022 14:55:06 GMT+0800 (Singapore Standard Time)' that I want to import to this >> 2022-08-03T06:55:06.410+00:00

Range
  • 3
  • 4

0 Answers0