Mongoimport ignore leading zero in csv

我们两清 提交于 2021-02-17 05:13:19

问题


I have a .CSV export file from a SQL Server database, with a phone number field (number type) that field values started with leading zero.

Leading zero is presented in the CSV file.

When I attempt to mongoimport it to DB (in string type) I find data imported without leading zero.

The target field number is string. How can I solve this problem?


回答1:


you can specifically define the type of the field using the import option --columnsHaveTypes

Instructs mongoimport that the field list specified in --fields, --fieldFile, or --headerline specifies the types of each field.

MongoDB Manual



来源:https://stackoverflow.com/questions/59436300/mongoimport-ignore-leading-zero-in-csv

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!