Hello All,
Requesting your guidance/help/inputs for date format specifiers which can be used to load date values from csv to collection. Here date is not simple date and time. It has addtional milliseconds and zone information as well.
Problem statement : Not able to add the milliseconds of time with .date() using mongoimport
I am able to manage this with compass tool i.e., data loading using ui
Data Inputs
-
CSV file contents:
101,“2023-11-28 10:29:21.533955+00:00”,“2023-11-28 10:29:21” -
File header columns not added to CSV
employee_id,date_01,date_02
- Command used to load csv
mongoimport "mongodb+srv://<connection_string>/" /username:<username>/password:<password> /d hr /c job_history /drop /file:"C:\Users\WorkFromHome\Desktop\JSON_DUMP\sample.csv" /type:csv /columnsHaveTypes /parseGrace:autoCast /fields:"employee_id.int32(),date_01.date(),date_02.date_oracle(YYYY-MM-DD HH24:MI:SS)"
Output/Observation:
"_id": {
"$oid": "6565c3c14d22c2463806b0bc"
},
"employee_id": 101,
"date_01": "2023-11-28 10:29:21.533955+00:00",
"date_02": {
"$date": "2023-11-28T10:29:21Z"
}
}
- date_01 - string
- date_02 - Date
Query/requirement
- Want to load the date_01 - “2023-11-28 10:29:21.533955+00:00” as date data type
- expected output- date data type : 2023-11-28T10:29:21.533955Z
I am looking for something like columnName.date(YYYY-MM-DD HH24:MI:SS…) which will accomodate the date.
If you could provide correct format specifier to handle milliseconds and time/zone or UTC time via mongoimport. I can change the input values accordingly.
Thank in advance,
Amol Naik