Use –parseGrace skipRow option.
mongoimport --type csv --parseGrace skipRow --file millionrecords.csv --headerline
–parseGrace grace
Default: stop
New in version 3.4.
Specifies how mongoimport handles type coercion failures when importing CSV or TSV files with –columnsHaveTypes.
–parseGrace has no effect when importing JSON documents.
- autoCast : Assigns a type based on the value of the field. For example, if a field is defined as a double and the value for that field was «foo», mongoimport would make that field value a string type.
- skipField : For the row being imported, mongoimport does not include the field whose type does not match the expected type.
- skipRow : mongoimport does not import rows containing a value whose type does not match the expected type.
- stop : mongoimport returns an error that ends the import.