Mongoimport忽略csv中的前导零 [英] Mongoimport ignore leading zero in csv
问题描述
我有一个来自 SQL Server 数据库的 .CSV
导出文件,其中包含一个电话号码字段(数字类型),该字段值以前导零开头.
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.
前导零显示在 CSV 文件中.
Leading zero is presented in the CSV file.
当我尝试将 mongoimport 导入数据库(字符串类型)时,我发现导入的数据没有前导零.
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?
推荐答案
您可以使用导入选项 --columnsHaveTypes
指示 mongoimport 在 --fields、--fieldFile 或 --headerline 中指定的字段列表指定每个字段的类型.
Instructs mongoimport that the field list specified in --fields, --fieldFile, or --headerline specifies the types of each field.
这篇关于Mongoimport忽略csv中的前导零的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!