I'm importing a text file with some columns being 000000
, 0000
, 000000000
. Google Docs converts them all to 0
– treating them as numbers. How do I make the columns contains exactly the string that was in the text file?
Google Sheets – How to Import Text File As-Is
google sheets
Related Topic
- Google Sheets – Adding Formulas to Google Forms Responses
- Google Sheets – Prevent ImportXML from Spilling Text Across Columns
- Google Sheets – How to Use ‘Split Text to Columns’ When Pasting
- Google Sheets – Keep Leading Zero with IMPORTDATA
- Convert Text String to Date/Time in Google Sheets
- Google-sheets – Import cells into the text of another cell preserving quotation marks
- Google Sheets – Convert Text to Number Ignoring Text
Best Answer
The column data
000000
, etc. is being seen as a number and consequently the leading zeros are being removed.Unfortunately, AFAIK, there is no way in Spreadsheet to format a number with leading zeros.In the old Google Spreadsheet there was no way to format a number with leading zeros. However, as mentioned by pnuts in comments, in the new Google Sheets you can specify a "Custom number format..." under Format > Number > More Formats. Specifying a format string such as0000
will format a number to 4 digits with leading zeros. The formatting would need to be done after the data is imported.However, if these data values are intended to be strings, then you will need to modify the source data by prefixing the data values with
'
(an apostrophe) in order to force a string value. For example: