Import or export text (.txt or .csv) files

There are two ways to import data from a text file with Excel: you can open it in Excel, or you can import it as an external data range. To export data from Excel to a text file, use the Save As command and change the file type from the drop-down menu.

There are two commonly used text file formats:

You can change the separator character that is used in both delimited and .csv text files. This may be necessary to make sure that the import or export operation works the way that you want it to.

Note: You can import or export up to 1,048,576 rows and 16,384 columns.

Import a text file by opening it in Excel

You can open a text file that you created in another program as an Excel workbook by using the Open command. Opening a text file in Excel does not change the format of the file — you can see this in the Excel title bar, where the name of the file retains the text file name extension (for example, .txt or .csv).

  1. Go to File >Open and browse to the location that contains the text file.
  2. Select Text Files in the file type dropdown list in the Open dialog box.
  3. Locate and double-click the text file that you want to open.
  4. If the file is a text file (.txt), Excel starts the Import Text Wizard. When you are done with the steps, click Finish to complete the import operation. See Text Import Wizard for more information about delimiters and advanced options.
  5. If the file is a .csv file, Excel automatically opens the text file and displays the data in a new workbook.

Note: When Excel opens a .csv file, it uses the current default data format settings to interpret how to import each column of data. If you want more flexibility in converting columns to different data formats, you can use the Import Text Wizard. For example, the format of a data column in the .csv file may be MDY, but Excel's default data format is YMD, or you want to convert a column of numbers that contains leading zeros to text so you can preserve the leading zeros. To force Excel to run the Import Text Wizard, you can change the file name extension from .csv to .txt before you open it, or you can import a text file by connecting to it (for more information, see the following section).

Import a text file by connecting to it

You can import data from a text file into an existing worksheet.

  1. Click the cell where you want to put the data from the text file.
  2. On the Data tab, in the Get & Transform Data group, click From Text/CSV.
  3. In the Import Data dialog box, locate and double-click the text file that you want to import, and click Import. Follow the instructions in the Text Import Wizard. Click Help

  1. Under Where do you want to put the data?, do one of the following:
  2. Optionally, click Properties to set refresh, formatting, and layout options for the imported data.
  3. Click OK. Excel puts the external data range in the location that you specify.

If Excel does not convert a column of data to the format that you want, you can convert the data after you import it. For more information, see Convert numbers stored as text to numbers and Convert dates stored as text to dates.

Export data to a text file by saving it

You can convert an Excel worksheet to a text file by using the Save As command.

  1. Go to File >Save As.
  2. The Save As dialog box appears.
  3. In the Save as type box, choose the text file format for the worksheet.
  4. For example, click Text (Tab delimited) or CSV (Comma delimited).

Note: The different formats support different feature sets. For more information about the feature sets that are supported by the different text file formats, see File formats that are supported in Excel.

For more information about saving files in other formats, see Save a workbook in another file format.

Import a text file by connecting to it (Power Query)

You can import data from a text file into an existing worksheet.

  1. On the Data tab, in the Get & Transform Data group, click From Text/CSV.
  2. In the Import Data dialog box, locate and double-click the text file that you want to import, and click Import.
  3. In the preview dialog box, you have several options:

If Excel doesn't convert a particular column of data to the format that you want, then you can convert the data after you import it. For more information, see Convert numbers stored as text to numbers and Convert dates stored as text to dates.

Export data to a text file by saving it

You can convert an Excel worksheet to a text file by using the Save As command.

  1. Go to File >Save As.
  2. Click Browse.
  3. In the Save As dialog box, under Save as type box, choose the text file format for the worksheet; for example, click Text (Tab delimited) or CSV (Comma delimited).

Note: The different formats support different feature sets. For more information about the feature sets that are supported by the different text file formats, see File formats that are supported in Excel.

For more information about saving files in other formats, see Save a workbook in another file format.

Change the delimiter that is used when importing a text file

The way you change the delimiter when importing is different depending on how you import the text.

Change the default list separator for saving files as text (.csv) in Excel

If you want to use a semi-colon as the default list separator when you Save As .csv, but need to limit the change to Excel, consider changing the default decimal separator to a comma - this forces Excel to use a semi-colon for the list separator. Obviously, this will also change the way decimal numbers are displayed, so also consider changing the Thousands separator to limit any confusion.

  1. Clear Excel Options >Advanced >Editing options >Use system separators.
  2. Set Decimal separator to , (a comma).
  3. Set Thousands separator to . (a period).
Change the default list separator for new text files (affects all programs)

When you save a workbook as a .csv file, the default list separator (delimiter) is a comma. You can change this to another separator character using Windows Region settings.

Caution: Changing the Windows setting will cause a global change on your computer, affecting all applications. To only change the delimiter for Excel, see Change the default list separator for saving files as text (.csv) in Excel.

  1. In Microsoft Windows 11, select the Search Bar and type Region Settings.
  2. Select Administrative language settings.
  3. Under the Formats tab, select Additional settings.
  4. In the Customize Format dialog, on the Numbers tab, type a character to use as the new separator in the List separator box.
  5. Select OK twice.
  1. In Microsoft Windows 10, right-click the Start button, and then click Settings.
  2. Click Time & Language, and then click Region in the left panel.
  3. In the main panel, under Regional settings, click Additional date, time, and regional settings.
  4. Under Region, click Change date, time, or number formats.
  5. In the Region dialog, on the Format tab, click Additional settings.
  6. In the Customize Format dialog, on the Numbers tab, type a character to use as the new separator in the List separator box.
  7. Select OK twice.
  1. In Microsoft Windows, click the Start button, and then click Control Panel.
  2. Under Clock, Language, and Region, click Change date, time, or number formats.
  3. In the Region dialog, on the Format tab, click Additional settings.
  4. In the Customize Format dialog, on the Numbers tab, type a character to use as the new separator in the List separator box.
  5. Select OK twice.

Note: After you change the list separator character for your computer, all programs use the new character as a list separator. You can change the character back to the default character by following the same procedure.

Need more help?

You can always ask an expert in the Excel Tech Community or get support in Communities.