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

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:

  • Delimited text files (.txt), in which the TAB character (ASCII character code 009) typically separates each field of text.

  • Comma separated values text files (.csv), in which the comma character (,) typically separates each field of text.

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.

    • 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.

    • 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).

Office 2010 - Office 2016Newer versions

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.

  4. Browse to the location where you want to save the new text file, and then click Save.

  5. A dialog box appears, reminding you that only the current worksheet will be saved to the new file. If you are certain that the current worksheet is the one that you want to save as a text file, click OK. You can save other worksheets as separate text files by repeating this procedure for each worksheet.

    You may also see an alert below the ribbon that some features might be lost if you save the workbook in a CSV format.

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

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 External Data group, click From Text.

  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 Import or export text (.txt or .csv) files (1) on any page of the Text Import Wizard for more information about using the wizard. When you are done with the steps in the wizard, click Finish to complete the import operation.

  4. In the Import Data dialog box, do the following:

    1. Under Where do you want to put the data?, do one of the following:

      • To return the data to the location that you selected, click Existing worksheet.

      • To return the data to the upper-left corner of a new worksheet, click New worksheet.

    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.

    • 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.

  4. Browse to the location where you want to save the new text file, and then click Save.

  5. A dialog box appears, reminding you that only the current worksheet will be saved to the new file. If you are certain that the current worksheet is the one that you want to save as a text file, click OK. You can save other worksheets as separate text files by repeating this procedure for each worksheet.

  6. A second dialog box appears, reminding you that your worksheet may contain features that are not supported by text file formats. If you are interested only in saving the worksheet data into the new text file, click Yes. If you are unsure and would like to know more about which Excel features are not supported by text file formats, click Help for more information.

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

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

  • If you use Get & Transform Data > From Text/CSV, after you choose the text file and click Import, choose a character to use from the list under Delimiter. You can see the effect of your new choice immediately in the data preview, so you can be sure you make the choice you want before you proceed.

  • If you use the Text Import Wizard to import a text file, you can change the delimiter that is used for the import operation in Step 2 of the Text Import Wizard. In this step, you can also change the way that consecutive delimiters, such as consecutive quotation marks, are handled.

    See Text Import Wizard for more information about delimiters and advanced options.

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. ClearExcel Options > Advanced > Editing options > Use system separators.

  2. Set Decimal separator to , (a comma).

  3. Set Thousands separator to . (a period).

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.

Windows 10Older versions

  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. Click 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. Click 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 Communityor get support inCommunities.

See Also

Import data from external data sources (Power Query)

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

FAQs

What is the best method to import data .TXT or .CSV file on Excel? ›

Import a text file by connecting to it
  1. Click the cell where you want to put the data from the text file.
  2. On the Data tab, in the Get External Data group, click From Text.
  3. In the Import Data dialog box, locate and double-click the text file that you want to import, and click Import.

What is the difference between CSV and TXT file in Python? ›

A CSV (comma separated values) file is a TXT file but has a special use. The values in a CSV file are separated by commas (thus the name) which can be imported into a spreadsheet application such as Excel. Other than that, there is no difference between a CSV and a TXT file.

Should I export to Excel or CSV? ›

The advantage of a CSV file over an Excel or other proprietary formats is that we can open and read a CSV file using just about any software, including plain text editors like TextEdit or NotePad. Hence these files are more robust and more likely to be accessible in the future.

How do I read a text file and convert it to CSV? ›

How to Convert a TXT file to CSV
  1. Open Excel and create a new spreadsheet.
  2. Select the Data tab.
  3. On the far right, click “Get External Data”, then select the “From Text” option.
  4. Find the TXT file on your computer and click “Open”.
  5. In the first step of the Import Wizard, select “Delimited”.

Why is CSV file preferred? ›

CSV is popular because it is easy to read and write, and it is supported by a wide range of software applications and programming languages. It is a lightweight and straightforward format that does not require any special software or complex parsing algorithms to handle.

What format is better than CSV? ›

Parquet files are smaller than CSV files, and they can be read and written much faster. Parquet files also support nested data structures, which makes them ideal for storing complex data. CSV: CSV is a row-based data format that is simple to read and write.

Is .TXT and .CSV the same? ›

CSV and TXT files store information in plain text. The first row in the file defines the names for all subsequent fields. In CSV files, fields are always separated by commas. In TXT files, fields can be separated with a comma, semicolon, or tab.

How do I convert .TXT to .CSV in Python? ›

Convert your text file into CSV using Python
  1. Step 1: Install Python onto your computer. Skip this step if you have done so previously. ...
  2. Step 2: Install the Pandas package. If you haven't already done so, install the Pandas package. ...
  3. Step 3: Convert text file to CSV. ...
  4. 6 Python Packages for Working with PDF Files.
Feb 12, 2022

Can a TXT file be a CSV? ›

Simply adding the ". csv" extension to a text file will change the file format itself to ". csv".

Why do people use CSV instead of Excel? ›

Editing and saving

One of the greatest advantages of CSV files is they can open with a simple text editor or another program. CSV files don't require proprietary software or applications to open, edit and save. XLS files execute with Microsoft Excel, and the extensions .

What is an example of a CSV file? ›

A CSV file is a list of data separated by commas. For instance, it may look like the following: Name,email,phone number,address. Example,example@example.com,555-555-5555,Example Address.

What is a CSV text file? ›

Comma-separated values (CSV) is a text file format that uses commas to separate values, and newlines to separate records. A CSV file stores tabular data (numbers and text) in plain text, where each line of the file typically represents one data record.

How do you convert a .TXT file to a .CSV file? ›

How to Change a TXT File to CSV
  1. Firstly, you'll need to open a new blank Excel document, then open the txt file in that new document. ...
  2. Navigate to the txt file you are looking to convert. ...
  3. Next, you'll see a Text Import Wizard pop-up. ...
  4. You'll then see the Excel sheet fill up as a completed CSV.

How do I convert a text file to CSV without opening it? ›

Do not open the file in a text editor like Microsoft Word! In Notepad on your PC, open the "File" menu and choose "Save As." Enter the name of your file and add the ". csv" extension. This will automatically change it to CSV format!

How do I extract data from a text file in Excel? ›

Use Excel's 'Get Data' Feature

Here are the steps to follow: Open Excel and select the 'Data' tab from the menu bar. Click on the 'Get Data' option and navigate to 'From Text/CSV' Locate and select your text file, then click 'Import'

How do I import data from txt to Excel? ›

  1. Save the text file to a folder on your computer. Open Microsoft Excel 2. Select File > Open 3. ...
  2. In the Text Import Wizard – Step 1 of 3 Pop-Up Box, choose Delimited. Click Next. ...
  3. In the Text Import Wizard – Step 3 of 3 Pop-Up Box, keep all fields the same. Click Finish.

What are the advantages of CSV file over Excel? ›

CSV Benefits
  • The files have a simple structure and are human-readable;
  • The data can be easily imported or exported into other programs;
  • CSV file format can be easily and accurately compressed;
  • The running costs are not high;
  • Perfect fit for getting data out of one application and into another one;

Why CSV is preferred over Excel? ›

It is a plain text format with a series of values separated by commas. CSV is safe and can clearly differentiate between the numeric values and text. CSV does not manipulate data and stores it as-is. Reading large files user is much easier in Excel for the end user.

Is it better to use JSON or CSV? ›

You should store data as CSV when working with structured data and have an issue with bandwidth. You should store data as JSON when you're working with unstructured and complex data.

Top Articles
Latest Posts
Article information

Author: Msgr. Benton Quitzon

Last Updated:

Views: 5469

Rating: 4.2 / 5 (63 voted)

Reviews: 94% of readers found this page helpful

Author information

Name: Msgr. Benton Quitzon

Birthday: 2001-08-13

Address: 96487 Kris Cliff, Teresiafurt, WI 95201

Phone: +9418513585781

Job: Senior Designer

Hobby: Calligraphy, Rowing, Vacation, Geocaching, Web surfing, Electronics, Electronics

Introduction: My name is Msgr. Benton Quitzon, I am a comfortable, charming, thankful, happy, adventurous, handsome, precious person who loves writing and wants to share my knowledge and understanding with you.