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:
-
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).
-
Go to File > Open and browse to the location that contains the text file.
-
Select Text Files in the file type dropdown list in the Open dialog box.
-
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).
-
Import a text file by connecting to it (Power Query)
You can import data from a text file into an existing worksheet.
-
On the Data tab, in the Get & Transform Data group, click From Text/CSV.
-
In the Import Data dialog box, locate and double-click the text file that you want to import, and click Import.
-
In the preview dialog box, you have several options:
-
Select Load if you want to load the data directly to a new worksheet.
-
Alternatively, select Load to if you want to load the data to a table, PivotTable/PivotChart, an existing/new Excel worksheet, or simply create a connection. You also have the choice of adding your data to the Data Model.
-
Select Transform Data if you want to load the data to Power Query, and edit it before bringing it to Excel.
-
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.
-
Go to File > Save As.
-
Click Browse.
-
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.
-
Browse to the location where you want to save the new text file, and then click Save.
-
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.
-
Click the cell where you want to put the data from the text file.
-
On the Data tab, in the Get External Data group, click From Text.
-
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 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.
-
In the Import Data dialog box, do the following:
-
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.
-
-
Optionally, click Properties to set refresh, formatting, and layout options for the imported data.
-
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.
-
Go to File > Save As.
-
The Save As dialog box appears.
-
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.
-
-
Browse to the location where you want to save the new text file, and then click Save.
-
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.
-
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.
-
Clear Excel Options > Advanced > Editing options > Use system separators.
-
Set Decimal separator to , (a comma).
-
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.
-
In Microsoft Windows 10, right-click the Start button, and then click Settings.
-
Click Time & Language, and then click Region in the left panel.
-
In the main panel, under Regional settings, click Additional date, time, and regional settings.
-
Under Region, click Change date, time, or number formats.
-
In the Region dialog, on the Format tab, click Additional settings.
-
In the Customize Format dialog, on the Numbers tab, type a character to use as the new separator in the List separator box.
-
Click OK twice.
-
In Microsoft Windows, click the Start button, and then click Control Panel.
-
Under Clock, Language, and Region, click Change date, time, or number formats.
-
In the Region dialog, on the Format tab, click Additional settings.
-
In the Customize Format dialog, on the Numbers tab, type a character to use as the new separator in the List separator box.
-
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 Community or get support in the Answers community.
See Also
Import data from external data sources (Power Query)
Need more help?
How to Import Data in Excel?
Importing the data from another file or another source file is often required in Excel. For example, sometimes people need data directly from very complicated servers, and sometimes we may need to import data from a text file or even from an Excel workbook.
If you are new to Excel data importing, then in this article, we will take a tour of importing data from text files, different Excel workbooks, and MS Access. Follow this article to learn the process involved in importing the data.
Table of contents
- How to Import Data in Excel?
- #1 – Import Data from Another Excel Workbook
- #2 – Import Data from MS Access to Excel
- #3 – Import Data from Text File to Excel
- Things to Remember
- Recommended Articles
#1 – Import Data from Another Excel Workbook
You can download this Import Data Excel Template here – Import Data Excel Template
Let us start.
- First, we must go to the DATA tab. Then, under the DATA tab, click on Connections.
- As soon as we click on Connections, we may see the below window separately.
- Now, click on Add.
- It will open up a new window. In the below window, select All Connections.
- If there are any connections in this workbook, it will show what those connections are here.
- Since we are connecting to a new workbook, click on Browse for more.
- In the below window, browse the file location. Then, click on Open.
- After clicking on Open, it shows the below window.
- Here, we need to select the required table to be imported to this workbook. Select the table and click on OK.
After clicking on OK, close the Workbook Connection window.
- Then, go to Existing Connections under the DATA tab.
- Here, we will see all the existing connections. Select the connection we have just made and click on Open.
- Once we click on Open, it will ask us where to import the data. First, we need to select the cell reference here. Then, click on the OK button.
- It will import the data from the selected or connected workbook.
Like this, we can connect to the other workbook and import the data.
#2 – Import Data from MS Access to Excel
MS Access is the main platform to store the data safely. We can import the data directly from the MS Access File itself whenever the data is required.
Step 1: Go to the “DATA” ribbon in excelThe ribbon is an element of the UI (User Interface) which is seen as a strip that consists of buttons or tabs; it is available at the top of the excel sheet. This option was first introduced in the Microsoft Excel 2007.read more and select “From Access.“
Step 2: Now, it will ask us to locate the desired file. Select the desired file path. Then, click on “Open.”
Step 3: Now, it will ask us to select the desired destination cell where we want to import the data. Then, click on “OK.”
Step 4: It will import the data from access to the A1 cell in Excel.
#3 – Import Data from Text File to Excel
In almost all the corporations, whenever we ask for the data from the IT team, they will write a query and get the file in TEXT format. But unfortunately, TEXT file data is not the ready format to use in Excel; we need to make some modifications to work on it.
Step 1: Go to the “DATA” tab and click on “From Text.”
Step 2: Now, it will ask us to choose the file location on the computer or laptop. Select the targeted file, then click on “Import.”
Step 3: It will open up a “Text Import Wizard.”
Step 4: By selecting the “Delimited,” click on “Next.”
Step 5: In the next window, select the other and mention comma (,) because, in the text file, each column is separated by a comma (,). Then click on “Next.”
Step 6: In the next window, click on “Finish.”
Step 7: Now, it will ask us to select the desired destination cell where we want to import the data. Select the cell and click on “OK.”
Step 8: It will import the data from the text file to the A1 cell in Excel.
Things to Remember
- If there are many tables, we must specify which table data we need to import.
- If we want the data in the current worksheet, we need to select the desired cell. Else, if we need data in a new worksheet, we must choose the new worksheet as the option.
- We need to separate the column in the TEXT file by identifying the common column separators.
Recommended Articles
This article is a guide to Import Data in Excel. Here, we discuss how to import data from 1) Excel Workbook, 2) MS Access, 3) Text File, practical examples, and a downloadable Excel template. You may learn more about Excel from the following articles: –
- KPI Dashboard in Excel
- Insert Image in Excel Cell
- How to Insert New Worksheet In Excel?
- Create a Dashboard in Excel
- Page Numbers in Excel
Excel can import and export many different file types aside from the standard .xslx format. If your data is shared between other programs, like a database, you may need to save data as a different file type or bring in files of a different file type.
Export Data
When you have data that needs to be transferred to another system, export it from Excel in a format that can be interpreted by other programs, such as a text or CSV file.
- Click the File tab.
- At the left, click Export.
- Click the Change File Type.
- Under Other File Types, select a file type.
- Text (Tab delimited): The cell data will be separated by a tab.
- CSV (Comma delimited): The cell data will be separated by a comma.
- Formatted Text (space delimited): The cell data will be separated by a space.
- Save as Another File Type: Select a different file type when the Save As dialog box appears.
The file type you select will depend on what type of file is required by the program that will consume the exported data.
- Click Save As.
- Specify where you want to save the file.
- Click Save.
A dialog box appears stating that some of the workbook features may be lost.
- Click Yes.
Import Data
Excel can import data from external data sources including other files, databases, or web pages.
- Click the Data tab on the Ribbon..
- Click the Get Data button.
Some data sources may require special security access, and the connection process can often be very complex. Enlist the help of your organization’s technical support staff for assistance.
- Select From File.
- Select From Text/CSV.
If you have data to import from Access, the web, or another source, select one of those options in the Get External Data group instead.
- Select the file you want to import.
- Click Import.
If, while importing external data, a security notice appears saying that it is connecting to an external source that may not be safe, click OK.
- Verify the preview looks correct.
Because we’ve specified the data is separated by commas, the delimiter is already set. If you need to change it, it can be done from this menu.
- Click Load.
FREE Quick Reference
Click to Download
Free to distribute with our compliments; we hope you will consider our paid training.
How to Import Text Files Into Excel: Step-by-Step Guide (2023)
Don’t you just wish you can magically import data that you need into a new usable format faster with nothing to do any manual work? 😩
Well, Microsoft Excel can grant your wish. Excel allows you to open other file formats such as comma-separated values (CSV) files and tab-separated (TXT) files. You can also import data from a text file by converting them into an Excel spreadsheet you can now work with.
Sounds awesome, right? 😀
Learn how to import data from a text file into Excel with our step-by-step guide.
Download this free practice workbook we’ve prepared for you to get started.
How to import a text or CSV file in Excel
Before you learn how to import a text file into Excel, you need to learn the basics of the text file formats first.
What is a text or CSV file?
Text files are formatted in a very specific way so they can be read by programs like Microsoft Excel. There are different text file formats. The commonly used ones are:
- Comma-separated values text files (.csv), in which the comma character (,) typically separates each field of text.
- Delimited text files (.txt), in which the TAB character typically separates each field of text.
Now, how does Excel reads data from a text or CSV file? 🤔
Each line of the file is a “record”. In Excel, that means it’s a row. Records are delineated by line breaks. Each line break corresponds to one row in Excel.
Delimiters such as commas, tabs, or space characters separate fields within the record. CSV files are comma delimited.
So, when Excel sees “Excel,CSV,Formatting”, it will import data in an Excel worksheet like this:
You can change the separator character that is used in CSV files or text files. This may be necessary to make sure that the import or export operation works the way that you want it to.
You can import or export up to 1,048,576 rows and 16,384 columns 👍
The only other notable thing about CSV files is that the double quote symbol indicates text fields. That’s important because text fields can contain commas and line breaks.
If they’re contained within quotes, commas, and line breaks won’t end the field or the record.
Prepare the Text File
Of course, in a real-life setting, you don’t need to prepare the text file. You may have already downloaded it in TXT or CSV file formats waiting to be imported into an Excel file.
For our tutorial, let’s open a Notepad File to create a sample text file. If you’re using Mac, open TextEdit📝
Type the following data in your notepad as shown below. Or copy this and paste it into your notepad.
Last Name,First Name,Address
Reed,James,Washington
Owens,Donovan,Texas
Hutchins,Ricky,Wisconsin
Then save this text file to be used later.
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. Let’s try to do each one of them 😊
Import a text or CSV file by opening it in Excel
The first way you can import text files in Excel is rather simple.
Just open a CSV file or a text file that you created in another program as an Excel workbook by using the Open command.
Open your practice workbook and do the following steps 👇
- Go to File Tab.
- Click Open.
- Browse to the location that contains the text file.
The Open dialog box pops up.
- Locate and double-click the text file that you want to open.
If you open a CSV file, Excel automatically opens the text file and displays the data in a new workbook. If the file is a text file, Excel starts the Text Import Wizard.
Since our file is a text file, the Text Import Wizard window pops up 🧙
There are 3 steps to go through. Let’s start with Step 1 out of 3.
The Text Import Wizard has determined that our data is Delimited. But to be sure:
- Click Delimited for the Original Data Type.
- Click Next to proceed to Step 2.
- Click Comma as the delimiter.
The window will also show a Data Preview Field.
- Click Next to proceed to Step 3.
Here you can select individual columns and apply specific formatting by clicking them and choosing an option from the Column data format list.
We’ll leave it as General, which is what you’ll most often use.
- Select General.
- Finally, click Finish to get your data.
This is now the result. The imported data is now in a new blank worksheet, not in your existing worksheet 😀
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).
Simple, right? 😊
Import a text or CSV file by connecting to it (Power Query)
You can also import data from a text file into an existing worksheet.
- Go to Data Tab.
- Click the Get Data drop-down button in the Get & Transform Data group.
- Select From File.
- Select From Text/CSV.
- In the Import Data dialog box, locate and double-click the text file that you want to import, and click Import.
In the preview dialog box, you have several options:
- Select Load if you want to load the data directly to a new worksheet.
- Select Load to if you want to load the data to a table, PivotTable/PivotChart, an existing worksheet, a new Excel worksheet, or simply create a connection. You also have the choice of adding your data to the Data Model.
- Select Transform Data if you want to load the data to Power Query, and edit it before bringing it to Excel.
- Click Transform Data.
The Text Power Query Editor window will pop up. It shows the data preview as well.
The data are already separated as you can see 👀
In the case that the data are NOT separated as they should be, here’s what to do: 👇
- Click the Split column button.
- Select By delimiter from the drop-down list.
- Select Comma as the delimiter.
- Click OK.
Look at the preview to check if it’s good to go.
As you can see, it added another unnecessary column. To remove or undo any changes you’ve done, head over to the Query Setting panel on the right side of the window.
Click the ❌ symbol. This will remove or undo any applied steps.
Look at the data preview again. If everything looks good…
- Finally, click the Close & Load button.
Now, this is what it will look like. The data is imported into a new worksheet in the current Excel workbook 😊
That’s it – Now what
Clearly, Microsoft Excel helps you import data from text files with just a few clicks. This saves you from manually typing data from other file formats by converting them to a usable file format you can work on 👍
If this sounds awesome already, then you are in for a big surprise! Excel can actually help you do 50 tasks all at once with just a single click 🤯
That’s right, this is possible with Excel Mighty Macros. It’s perfect for your workflow automation. Learn how to record, and edit a macro, the basics of the VBA editor, and learn how to write your first macro from scratch. Learn it all with me!
Join my free email course to get started with macros. It’s free and perfect for beginners 😊
Kasper Langmann2023-02-02T18:55:50+00:00
Page load link
This article will show you how to easily add/attach file like PDF, Word or any other to Excel spreadsheet.
Applies to: Excel, Excel 2013, Excel 2016, Excel 2019, Excel 365, Office 365
-
Go to Insert tab
Excel 2016/2019/365 — Home tab
-
Click Object button placed in Text group.
Narrow window
Insert Object button — narrow window
Medium width window
Insert Object button — medium width window
Maximum width window
Insert Object button — max width window
-
Click Create from file and browse for the file.
Click to enlarge