csv sample
timestamp,name,amount
1571967208,Rahul,15.7
1571967200,Raju,25.7
code sample
mongoimport --db=crypto --collection=t --type=csv \
--columnsHaveTypes \
--fields="timestamp.date(), name.string(), amount.double()" \
--file="text.csv"
result
Failed: type coercion failure in document #1 for column 'timestamp', could not parse token '1571967208' to type date
You could pre-process your CSV into MongoDB Extended JSON (v2) using
jqwith something like:This would transform your example CSV into:
See jqplay.org example.
and then: