Sub topic 5
Separator type and converting text to numbers, dates and formulas
This chapter covers the two settings in the File > Import dialog that decide how a delimited text file becomes cells: Separator type and Convert text to numbers, dates, and formulas. It assumes you can upload files to Google Drive, know what a CSV file is, and can use basic formulas such as TRIM and TEXT. It also assumes you have already seen the import dialog and the import location options from the previous chapters.
Why these two settings matter
A CSV file is plain text. It has no cell types, no column widths and no formulas. Each line is a row, and a delimiter character splits each line into fields. Google Sheets has to make two decisions about every file:
- Where does one field end and the next begin? The separator type controls this.
- Is the text
00123a number, a date, a code or a word? The conversion option controls this.
Both decisions happen once, at import time. If either is wrong, you get shifted columns, numbers stored as text, or dates that are silently wrong. Fixing the settings and importing again is usually easier than repairing the damaged cells.
Separator type
When you pick a CSV, TSV or TXT file, the dialog shows a Separator type list. This list does not appear for Excel files such as XLSX, because those store cells in a structured format and need no delimiter.
| Option | Splits fields on | Typical source | Column |
|---|---|---|---|
| Detect automatically | Whatever Sheets guesses from the file | Most files | |
| Tab | A tab character | TSV files, copied tables | |
| Comma | `,` | US and UK exports | |
| Semicolon | `;` | Exports from locales that use a decimal comma | |
| Custom | A character you type | Pipe-separated (`\ | `) or other exports |
When to leave it on automatic
Automatic detection works for clean files. It can fail when:
- The file has only one column, so there is no delimiter to find.
- Text fields contain many commas, semicolons or tabs, which makes the guess ambiguous.
- The first lines are a title or notes rather than data, so the sample the guess is based on is not representative.
If everything lands in column A, the separator was not detected. If a text column is split in two, the wrong separator was chosen. In both cases, set the separator by hand and import again.
Quoted fields
The usual CSV convention puts double quotes around a field that contains the delimiter:
id,name,city
1,"Smith, Anna",Leeds
2,"Okafor, Chidi",LagosSheets understands this. With the Comma separator, "Smith, Anna" stays in one cell, and the quotes are not shown. The problem appears only when the file is malformed, for example when a field contains a comma but has no quotes. Then that row has an extra column. Check for this by scrolling to the right after import and looking for stray values beyond the last header.
The custom separator
Choosing Custom shows a box for one character. Use it for pipes (|), tildes (~) or other characters. Enter a single character. The Custom box is for a single-character delimiter, so a multi-character delimiter such as || is not something to rely on. If your file uses one, replace it with a single character in a text editor before importing.
Semicolon files and decimal commas
In many European locales the comma is the decimal mark, so 3,14 means 3.14. A CSV exported there usually uses semicolons as the field separator to avoid a clash:
product;price
Tea;3,14
Coffee;4,50Two settings must agree for this file to import as numbers. The separator must be Semicolon, and the spreadsheet locale must be one that reads a comma as the decimal mark. If the locale is United States, 3,14 is not recognized as a number. The next chapters return to locale in detail. For now, remember that separators decide the cell boundaries and locale decides how the text inside a cell is read.
Convert text to numbers, dates, and formulas
Below the separator list is a checkbox named Convert text to numbers, dates, and formulas. It is checked by default.
Checked: Sheets interprets each field
With the box checked, Sheets looks at each field and applies the same parsing it would apply if you typed the value into a cell. You get these results:
42and3.14become numbers, right-aligned, and can be summed.2025-03-14becomes a date with a date format.TRUEandFALSEbecome Boolean values.- A field that starts with
=becomes a formula and is calculated. 00123becomes the number 123, and the leading zeros are lost.
Unchecked: everything stays text
With the box unchecked, each field is stored as text exactly as it appears in the file. 00123 keeps its zeros, 2025-03-14 stays a string, and =A1+1 shows as literal text. Numbers imported this way are left-aligned and SUM ignores them.
Neither setting is always right. Use this table to choose.
| Situation | Setting | Reason |
|---|---|---|
| Prices, quantities, measurements you will calculate with | Checked | You need real numbers |
| Dates you will sort or filter | Checked, with the correct locale | Dates become real date values |
| ZIP codes, phone numbers, product codes, IDs | Unchecked | Leading zeros and exact digits are preserved |
| Long numeric IDs of 16 or more digits | Unchecked | Numbers lose precision beyond about 15 significant digits |
| Files from sources you do not trust | Unchecked | Text beginning with `=` will not run as a formula |
The formula risk
A field such as =HYPERLINK("https://example.com","Click") in a CSV becomes a live formula when conversion is on. Some formulas can fetch data from other URLs, such as IMPORTDATA or IMPORTXML. This is called formula injection. Treat an unfamiliar CSV that contains cells beginning with =, +, - or @ with caution, and import it unchecked.
Mixed files: import as text, convert selectively
A common pattern is to import with conversion off, then convert only the columns that should be numbers or dates. The advantage is that you decide column by column, and the original text stays available to compare against.
For a text column that holds numbers (such as one imported with conversion off), VALUE converts it:
=ARRAYFORMULA(VALUE(C2:C))Wrapping this in IF stops blank cells from producing errors:
=ARRAYFORMULA(IF(C2:C="", "", VALUE(C2:C)))For dates in the ISO form YYYY-MM-DD, DATEVALUE converts them:
=ARRAYFORMULA(IF(B2:B="", "", DATEVALUE(B2:B)))The result is a serial number. Apply a date format with Format > Number > Date to display it as a date. DATEVALUE reads text according to the spreadsheet locale, so an ISO date is the safest input because every locale understands it.
What happens to dates
When conversion is on, ambiguous dates are the main danger. Take the text 03/04/2025. In a US locale it is March 4. In a UK locale it is 3 April. Sheets does not warn you. It picks according to the spreadsheet locale and stores a valid date either way.
A second trap affects values like 13/04/2025 in a US locale. There is no month 13, so Sheets cannot read the field as a date and leaves it as text. The column then mixes real dates (the rows where the day is 12 or less) and text (the others). Sort the column and you will see the text values grouped apart. This mixing is the usual sign that the locale does not match the file.
To check which cells are real dates, use:
=ARRAYFORMULA(ISDATE(A2:A))ISDATE returns FALSE for text that only looks like a date. To count the problems, use =COUNTIF(D2:D, FALSE) on a helper column that holds these results.
Working example
Suppose a file orders.csv contains this:
order_id,zip,order_date,amount
1001,02134,2025-03-14,19.90
1002,90210,2025-03-15,5.00
1003,00501,2025-03-16,7.25- Choose File > Import > Upload and select the file.
- Set Import location to Create new spreadsheet.
- Set Separator type to Comma.
- Uncheck Convert text to numbers, dates, and formulas.
- Click Import data.
All four columns now hold text, and the ZIP codes keep their zeros. Next, convert only the numeric and date columns. In a spare area, for instance column F, put:
=ARRAYFORMULA(IF(D2:D="", "", VALUE(D2:D)))and in column G:
=ARRAYFORMULA(IF(C2:C="", "", DATEVALUE(C2:C)))Format column G as a date. You then have exact ZIP codes, numeric amounts and real dates. If you had imported with conversion on, the ZIP column would hold 2134, 90210 and 501, and you would repair it with =TEXT(B2, "00000"). That repair works only because every ZIP has five digits. Importing as text avoids needing the repair.
The same two decisions in Apps Script
If you automate imports with Apps Script, the same decisions appear in code. Utilities.parseCsv takes an optional delimiter as its second argument, which is the equivalent of Separator type:
function importSemicolonCsv() {
const fileId = 'YOUR_FILE_ID';
const text = DriveApp.getFileById(fileId).getBlob().getDataAsString('UTF-8');
const rows = Utilities.parseCsv(text, ';');
const sheet = SpreadsheetApp.getActiveSpreadsheet().insertSheet('Imported');
const range = sheet.getRange(1, 1, rows.length, rows[0].length);
range.setNumberFormat('@');
range.setValues(rows);
}setNumberFormat('@') applies the plain text format before the values are written. That is the script equivalent of unchecking the conversion box. Without it, setValues passes strings through the same parsing as typed input, so 00123 would become the number 123. Set the format first, then write.
Common mistakes
- Everything in column A. The separator was not detected. Re-import with an explicit separator.
- Numbers that will not sum. They were imported as text. Check for left alignment, then convert with
VALUE, or re-import with conversion on. - Zeros gone from codes. Conversion was on. Re-import with it off, or restore with
TEXT. - Dates swapped between day and month. The spreadsheet locale does not match the file. Change the locale under File > Settings, then re-import.
- Formula errors such as
#NAME?or#REF!in imported cells. Fields beginning with=were treated as formulas. Re-import with conversion off. - Changing the setting afterward expecting a fix. The checkbox applies only during import. It does not change cells already in the sheet.
Exercise
A semicolon-separated file from a German supplier has a price column with values like 12,50. You import it with the separator on Comma and conversion on. Describe what you will see and give the two settings that must change.
Show answer
With the Comma separator, every price splits at its decimal comma, so 12,50 is cut into two cells (12 and 50), and rows shift to the right. The semicolon-separated fields are not split, so each row holds long strings with semicolons inside. To fix it, set Separator type to Semicolon (or Detect automatically if it guesses correctly), and set the spreadsheet locale to one that uses a decimal comma, such as Germany, so 12,50 converts to the number 12.5. Then import again.
Exercise
A CSV has a column sku with values like 007421. You need the zeros kept and also need an amount column you can sum. What import setting do you use, and how do you get numeric amounts?
Show answer
Uncheck "Convert text to numbers, dates, and formulas" so sku stays text with its zeros. The amount column is then text too, so convert it with =ARRAYFORMULA(IF(C2:C="", "", VALUE(C2:C))) (adjusting the column letter) and use the results for sums. Alternatively, import with conversion on and restore the SKUs with =TEXT(A2, "000000"), which works only because every SKU has six digits.