0

MongoDB seems to have trouble importing data, I tried to import csv file with values having leading zeros enclosed in double quotes but once imported the leading zeros gets removed.

Sample CSV File

duns_number,company_name,type,country,original_company_name,search_key,cik,last_scraped_date
"194946757","Carbonite, Inc.",Public,United States,,,"0001340127",
"116670284",SolarWinds Corp,Public,United States,SolarWinds Corporation,,"0001739942",

Sample Import Script

mongoimport --type csv -d ds_dnb -c ds_company_masterlist  --headerline --drop ""

Is there any other way of forcing it to just import the data as all text?

turivishal
  • 34,368
  • 7
  • 36
  • 59
apelidoko
  • 782
  • 1
  • 7
  • 23
  • 2
    There is an option (parameter) called as `--columnsHaveTypes`, where you can specify the field type (in your case `string`) of the column being imported - try that one. – prasad_ Jan 21 '21 at 05:22
  • https://stackoverflow.com/questions/24223443/mongoimport-choosing-field-type – R2D2 Jan 21 '21 at 07:40

0 Answers0