Import data to excel from text

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

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

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:

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

  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 button image 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. Clear Excel 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.

  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 Community or get support in the Answers community.

See Also

Import data from external data sources (Power Query)

Need more help?

Excel for Microsoft 365 Excel 2021 Excel 2019 Excel 2016 Excel 2013 Excel 2010 Excel 2007 Excel Starter 2010 More…Less

Although you can’t export to Excel directly from a text file or Word document, you can use the Text Import Wizard in Excel to import data from a text file into a worksheet. The Text Import Wizard examines the text file that you are importing and helps you ensure that the data is imported in the way that you want.     

Go to the Data tab > Get External DataFrom Text. Then, in the Import Text File dialog box, double-click the text file that you want to import, and the Text Import Wizard dialog will open.

Step 1 of 3

Original data type    If items in the text file are separated by tabs, colons, semicolons, spaces, or other characters, select Delimited. If all of the items in each column are the same length, select Fixed width.

Start import at row    Type or select a row number to specify the first row of the data that you want to import.

File origin    Select the character set that is used in the text file. In most cases, you can leave this setting at its default. If you know that the text file was created by using a different character set than the character set that you are using on your computer, you should change this setting to match that character set. For example, if your computer is set to use character set 1251 (Cyrillic, Windows), but you know that the file was produced by using character set 1252 (Western European, Windows), you should set File Origin to 1252.

Preview of file    This box displays the text as it will appear when it is separated into columns on the worksheet.

Step 2 of 3 (Delimited data)

Delimiters    Select the character that separates values in your text file. If the character is not listed, select the Other check box, and then type the character in the box that contains the cursor. These options are not available if your data type is Fixed width.

Treat consecutive delimiters as one    Select this check box if your data contains a delimiter of more than one character between data fields or if your data contains multiple custom delimiters.

Text qualifier    Select the character that encloses values in your text file. When Excel encounters the text qualifier character, all of the text that follows that character and precedes the next occurrence of that character is imported as one value, even if the text contains a delimiter character. For example, if the delimiter is a comma (,) and the text qualifier is a quotation mark («), «Dallas, Texas» is imported into one cell as Dallas, Texas. If no character or the apostrophe (‘) is specified as the text qualifier, «Dallas, Texas» is imported into two adjacent cells as «Dallas and Texas».

If the delimiter character occurs between text qualifiers, Excel omits the qualifiers in the imported value. If no delimiter character occurs between text qualifiers, Excel includes the qualifier character in the imported value. Hence, «Dallas Texas» (using the quotation mark text qualifier) is imported into one cell as «Dallas Texas».

Data preview    Review the text in this box to verify that the text will be separated into columns on the worksheet as you want it.

Step 2 of 3 (Fixed width data)

Data preview    Set field widths in this section. Click the preview window to set a column break, which is represented by a vertical line. Double-click a column break to remove it, or drag a column break to move it.

Step 3 of 3

Click the Advanced button to do one or more of the following:

  • Specify the type of decimal and thousands separators that are used in the text file. When the data is imported into Excel, the separators will match those that are specified for your location in Regional and Language Options or Regional Settings (Windows Control Panel).

  • Specify that one or more numeric values may contain a trailing minus sign.

Column data format    Click the data format of the column that is selected in the Data preview section. If you do not want to import the selected column, click Do not import column (skip).

After you select a data format option for the selected column, the column heading under Data preview displays the format. If you select Date, select a date format in the Date box.

Choose the data format that closely matches the preview data so that Excel can convert the imported data correctly. For example:

  • To convert a column of all currency number characters to the Excel Currency format, select General.

  • To convert a column of all number characters to the Excel Text format, select Text.

  • To convert a column of all date characters, each date in the order of year, month, and day, to the Excel Date format, select Date, and then select the date type of YMD in the Date box.

Excel will import the column as General if the conversion could yield unintended results. For example:

  • If the column contains a mix of formats, such as alphabetical and numeric characters, Excel converts the column to General.

  • If, in a column of dates, each date is in the order of year, month, and date, and you select Date along with a date type of MDY, Excel converts the column to General format. A column that contains date characters must closely match an Excel built-in date or custom date formats.

If Excel does not convert a column to the format that you want, you can convert the data after you import it.

  • Convert numbers stored as text to numbers

  • Convert dates stored as text to dates

  • TEXT function

  • VALUE function

When you have selected the options you want, click Finish to open the Import Data dialog and choose where to place your data.

Import Data

Set these options to control how the data import process runs, including what data connection properties to use and what file and range to populate with the imported data.

  • The options under Select how you want to view this data in your workbook are only available if you have a Data Model prepared and select the option to add this import to that model (see the third item in this list).

  • Specify a target workbook:

    • If you choose Existing Worksheet, click a cell in the sheet to place the first cell of imported data, or click and drag to select a range.

    • Choose New Worksheet to import into a new worksheet (starting at cell A1)

  • If you have a Data Model in place, click Add this data to the Data Model to include this import in the model. For more information, see Create a Data Model in Excel.

    Note that selecting this option unlocks the options under Select how you want to view this data in your workbook.

  • Click Properties to set any External Data Range properties you want. For more information, see Manage external data ranges and their properties.

  • Click OK when you’re ready to finish importing your data.

Notes: The Text Import Wizard is a legacy feature, which may need to be enabled. If you haven’t already done so, then: 

  1. Click File > Options > Data.

  2. Under Show legacy data import wizards, select From Text (Legacy).

Once enabled, go to the Data tab > Get & Transform Data > Get Data > Legacy Wizards > From Text (Legacy). Then, in the Import Text File dialog box, double-click the text file that you want to import, and the Text Import Wizard will open.

Step 1 of 3

Original data type    If items in the text file are separated by tabs, colons, semicolons, spaces, or other characters, select Delimited. If all of the items in each column are the same length, select Fixed width.

Start import at row    Type or select a row number to specify the first row of the data that you want to import.

File origin    Select the character set that is used in the text file. In most cases, you can leave this setting at its default. If you know that the text file was created by using a different character set than the character set that you are using on your computer, you should change this setting to match that character set. For example, if your computer is set to use character set 1251 (Cyrillic, Windows), but you know that the file was produced by using character set 1252 (Western European, Windows), you should set File Origin to 1252.

Preview of file    This box displays the text as it will appear when it is separated into columns on the worksheet.

Step 2 of 3 (Delimited data)

Delimiters    Select the character that separates values in your text file. If the character is not listed, select the Other check box, and then type the character in the box that contains the cursor. These options are not available if your data type is Fixed width.

Treat consecutive delimiters as one    Select this check box if your data contains a delimiter of more than one character between data fields or if your data contains multiple custom delimiters.

Text qualifier    Select the character that encloses values in your text file. When Excel encounters the text qualifier character, all of the text that follows that character and precedes the next occurrence of that character is imported as one value, even if the text contains a delimiter character. For example, if the delimiter is a comma (,) and the text qualifier is a quotation mark («), «Dallas, Texas» is imported into one cell as Dallas, Texas. If no character or the apostrophe (‘) is specified as the text qualifier, «Dallas, Texas» is imported into two adjacent cells as «Dallas and Texas».

If the delimiter character occurs between text qualifiers, Excel omits the qualifiers in the imported value. If no delimiter character occurs between text qualifiers, Excel includes the qualifier character in the imported value. Hence, «Dallas Texas» (using the quotation mark text qualifier) is imported into one cell as «Dallas Texas».

Data preview    Review the text in this box to verify that the text will be separated into columns on the worksheet as you want it.

Step 2 of 3 (Fixed width data)

Data preview    Set field widths in this section. Click the preview window to set a column break, which is represented by a vertical line. Double-click a column break to remove it, or drag a column break to move it.

Step 3 of 3

Click the Advanced button to do one or more of the following:

  • Specify the type of decimal and thousands separators that are used in the text file. When the data is imported into Excel, the separators will match those that are specified for your location in Regional and Language Options or Regional Settings (Windows Control Panel).

  • Specify that one or more numeric values may contain a trailing minus sign.

Column data format    Click the data format of the column that is selected in the Data preview section. If you do not want to import the selected column, click Do not import column (skip).

After you select a data format option for the selected column, the column heading under Data preview displays the format. If you select Date, select a date format in the Date box.

Choose the data format that closely matches the preview data so that Excel can convert the imported data correctly. For example:

  • To convert a column of all currency number characters to the Excel Currency format, select General.

  • To convert a column of all number characters to the Excel Text format, select Text.

  • To convert a column of all date characters, each date in the order of year, month, and day, to the Excel Date format, select Date, and then select the date type of YMD in the Date box.

Excel will import the column as General if the conversion could yield unintended results. For example:

  • If the column contains a mix of formats, such as alphabetical and numeric characters, Excel converts the column to General.

  • If, in a column of dates, each date is in the order of year, month, and date, and you select Date along with a date type of MDY, Excel converts the column to General format. A column that contains date characters must closely match an Excel built-in date or custom date formats.

If Excel does not convert a column to the format that you want, you can convert the data after you import it.

  • Convert numbers stored as text to numbers

  • Convert dates stored as text to dates

  • TEXT function

  • VALUE function

When you have selected the options you want, click Finish to open the Import Data dialog and choose where to place your data.

Import Data

Set these options to control how the data import process runs, including what data connection properties to use and what file and range to populate with the imported data.

  • The options under Select how you want to view this data in your workbook are only available if you have a Data Model prepared and select the option to add this import to that model (see the third item in this list).

  • Specify a target workbook:

    • If you choose Existing Worksheet, click a cell in the sheet to place the first cell of imported data, or click and drag to select a range.

    • Choose New Worksheet to import into a new worksheet (starting at cell A1)

  • If you have a Data Model in place, click Add this data to the Data Model to include this import in the model. For more information, see Create a Data Model in Excel.

    Note that selecting this option unlocks the options under Select how you want to view this data in your workbook.

  • Click Properties to set any External Data Range properties you want. For more information, see Manage external data ranges and their properties.

  • Click OK when you’re ready to finish importing your data.

Note: If your data is in a Word document, you must first save it as a text file. Click File > Save As, and choose Plain Text (.txt) as the file type.

Need more help?

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

See Also

Introduction to Microsoft Power Query for Excel

Need more help?

I have multiple folders. There are multiple txt files inside these folder. I need to extract data (just a single value: value —>554) from a particular type of txt file in this folder.(individual_values.txt)

No  100    Value   555      level match   0.443        top level  0.443       bottom 4343

There will be many folders with same txt file names but diff value. Can all these values be copyed to excel one below the other.

I have to extract a value from a txt file which i mentioned above. Its a same text file with same name located inside different folders. All i want to do is extract this value from all the text file and paste it in excel or txt one below the other in each row.

Eg: The above is a text file here I have to get the value of 555 and similarly from other diff values.

555

666

666

776

brian d foy's user avatar

brian d foy

128k31 gold badges205 silver badges585 bronze badges

asked Aug 6, 2009 at 20:55

user150674's user avatar

3

Yes.

(you might want to clarify your question )

answered Aug 6, 2009 at 20:59

Byron Whitlock's user avatar

Byron WhitlockByron Whitlock

52.3k28 gold badges123 silver badges167 bronze badges

0

Your question isn’t very clear, I imagine you want to know how this can be done.

You probably need to write a script that traverses the folders, reads the individual files, parses them for the value you want, and generates a Comma Separated Values (CSV) file. CSV files can easily be imported to Excel.

answered Aug 6, 2009 at 21:03

Sinan Taifour's user avatar

Sinan TaifourSinan Taifour

10.4k3 gold badges32 silver badges30 bronze badges

There are two or three basic methods you can use to get stuff into a Excel Spreadsheet.

  • You can use OLE wrappers to manipulate Excel.
  • You can write the file in a binary form
  • You can use Excel’s import methods to take delimited text in as a spreadsheet.

I chose the latter way, because 1) it is the simplest, and 2) your problem is so poorly stated as it does not require a more complex way. The solution below outputs a tab-delimited text file that Excel can easily support.

In Perl:

use IO::File;

my @field_names = split m|/|, 'No/Value/level match/top level/bottom';
#' # <-- catch runaway quote

my $input    = IO::File->new( '<data.txt' );
die 'Could not open data.txt for input!' unless $input;

my @data_rows;
while ( my $line = <$input> ) { 
    my %fields = $line =~ /(level match|top level|bottom|Value|No)s+(d+S*)/g;
    push @data_rows, %fields if exists $fields{Value};
}

$input->close();

my $tab_file = IO::File->new( '>data.tab' );
die 'Could not open data.tab for output!' unless $tab_file;

$tab_file->print( join( "t", @field_names ), "n" );
foreach my $data_ref ( @data ) { 
    $tab_file->print( join( "t", @$data_ref{@field_names} ), "n" );
}

$tab_file->close();

NOTE: Excel’s text processing is really quite neat. Try opening the text below (replacing the t with actual tabs) — or even copying and pasting it:

1t2t3t=SUM(A1:C1)

answered Aug 6, 2009 at 22:02

Axeman's user avatar

AxemanAxeman

29.6k2 gold badges47 silver badges102 bronze badges

3

I chose c#, because i thought it would be fun to use a recursive lambda. This will create the csv file containing matches to the regex pattern.

    string root_path = @"c:Temptest";
    string match_filename = "test.txt";

    Func<string,string,StringBuilder, StringBuilder> getdata = null;

    getdata = (path,filename,content) => {
        Directory.GetFiles(path)
        .Where(f=>
            Path.GetFileName(f)
            .Equals(filename,StringComparison.OrdinalIgnoreCase))
        .Select(f=>File.ReadAllText(f))
        .Select(c=> Regex.Match(c, @"value[st]*(d+)",
            RegexOptions.IgnoreCase))
        .Where(m=>m.Success)
        .Select(m=>m.Groups[1].Value)
        .ToList()
        .ForEach(m=>content.AppendLine(m));
        Directory.GetDirectories(path)
            .ToList()
            .ForEach(d=>getdata(d,filename,content));
                return content;
    };
    File.WriteAllText(
        Path.Combine(root_path, "data.csv"),
        getdata(root_path, match_filename, new StringBuilder()).ToString());

answered Aug 7, 2009 at 2:36

ccook's user avatar

ccookccook

5,8596 gold badges54 silver badges81 bronze badges

No.

just making sure you have a 50/50 chance of getting the right answer

(assuming it was a question answerable by Yes and No) hehehe

answered Aug 6, 2009 at 21:00

pageman's user avatar

pagemanpageman

2,8441 gold badge29 silver badges38 bronze badges

1

File_not_found

Gotta have all three binary states for the response.

answered Aug 6, 2009 at 21:24

Oesor's user avatar

OesorOesor

6,6022 gold badges28 silver badges56 bronze badges

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

Import Data into Excel

#1 – Import Data from Another Excel Workbook

You can download this Import Data Excel Template here – Import Data Excel Template

Let us start.

  1. First, we must go to the DATA tab. Then, under the DATA tab, click on Connections.

    Import Data Example 1

  2. As soon as we click on Connections, we may see the below window separately.

    Import Data Example 1-1

  3. Now, click on Add.

    Import Data Example 1-2

  4. It will open up a new window. In the below window, select All Connections.

    Import Data Example 1-3

  5. If there are any connections in this workbook, it will show what those connections are here.

    Import Data Example 1-4

  6. Since we are connecting to a new workbook, click on Browse for more.

    Import Data Example 1-5

  7. In the below window, browse the file location. Then, click on Open.

    Import Data Example 1-6

  8. After clicking on Open, it shows the below window.

    Import Data Example 1-7

  9. Here, we need to select the required table to be imported to this workbook. Select the table and click on OK.

    Import Data Example 1-8

    After clicking on OK, close the Workbook Connection window.

  10. Then, go to Existing Connections under the DATA tab.

    Import Data Example 1-9

  11. Here, we will see all the existing connections. Select the connection we have just made and click on Open.

    Import Data Example 1-10

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

    Import Data Example 1-11

  13. It will import the data from the selected or connected workbook.

    Import Data Example 1-12

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.

Import Data Example 2

Step 2: Now, it will ask us to locate the desired file. Select the desired file path. Then, click on “Open.”

Import Data Example 2-1

Step 3: Now, it will ask us to select the desired destination cell where we want to import the data. Then, click on “OK.”

Import Data Example 2-2

Step 4: It will import the data from access to the A1 cell in Excel.

Import Data Example 2-3

#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.”

Example 3

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

Example 3-1

Step 3: It will open up a “Text Import Wizard.”

Text Import Wizard - Step 1 of 3

Step 4: By selecting the “Delimited,” click on “Next.”

Text Import Wizard - Step 1 of 3

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

Text Import Wizard - Step 2 of 3

Step 6: In the next window, click on “Finish.”

Text Import Wizard 3-5

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

Example 3-6

Step 8: It will import the data from the text file to the A1 cell in Excel.

Example 3-7

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

Different applications generate data in different forms.

A SaaS application might generate a report in the form of a PDF, while another application might generate data in the form of a TXT or CSV file.

The challenge lies in consolidating the data into a single application that can work with all the data to produce the required results.

Microsoft Excel is one application that is frequently used for this, owing to its versatility in importing data from files with a wide variety of extensions.  

For example, if you have a list of items saved in a Text file (or in Notepad), Excel allows you to import this list so that you can process it further.

In this tutorial we will show you two ways to convert a text file to Excel:

  • By using the Text Import Wizard
  • By opening the file directly in Excel

What is a Text File?

A Text file is one that contains text with no special formatting (as in bold, italic, images, etc.).

These files are identified with the ‘.txt’ extension and can be opened in any text editor, like Notepad or word processor, like Microsoft Word.

But in many cases, you can have data in a text file that you need to open in Excel and analyze there.

Thankfully, you can easily open text files in Microsoft Excel and then further work on it.

Let’s see how to do that!

Let us look at two ways in which we can convert a Text file (.txt) to Excel.

Method 1: Using the Text Import Wizard to Convert a Text File to Excel

If you have a spreadsheet open in Excel and want to import the contents of a Text file at a specific area of your spreadsheet, the Text Import Wizard might be the best way to go.

This wizard scans your text file and ensures that the data in the file is imported the way you want.

To use the Text Import Wizard, select the Data tab, followed by ‘From Text’ (which you will find under the ‘Get External Data’ group. 

Click on the From Text option

After this, select the text file that you want to import.

Select the text file that you want to open

Your Text Import Wizard should now open automatically. 

Text Import Wizard

The Text Import Wizard guides you in providing the best settings to import your text file data through 3 steps:

Step 1 of 3

In this step you can provide the settings for the following:

  • Original Data Type: Here you can choose how you want your data to be separated into columns. You have two options:
    • Delimited: Select this if your text file data is separated by tabs, colons, semicolons or other characters.
    • Fixed width: Select this if all items in each column of your data are the same width.
  • Start import at row: Type or select the first row of your data from where you want to start importing.
  • File origin: Select the character set that your text file uses, for example 437 (for the OEM United States character set). Usually, it’s fine to leave this at the default setting.
  • My data has headers: Keep this field checked if your Text file’s dataset contains headers.
Step 1 settings for text import wizard

Step 2 of 3

If you had selected the ‘Delimited’ radio button in Step 1, then this step lets you specify the delimiters that your data contains (for example tabs, commas, semicolons, etc.) You can also specify if you want consecutive delimiters to be counted as one. 

Moreover, if your text values are enclosed in a special set of characters (for example in single or double quotes), then you can specify the character in this step.

These characters are known as ‘Text qualifiers’ and help specify if you want a set of values to be imported as one.

For example, “Scott, Steve” is imported as a single value, even though the words are separated by a comma delimiter.

Step 2 settings for text import wizard

At the bottom of the screen, you can see a preview of how your data will get affected in the spreadsheet after conversion.

If you had selected the ‘Fixed Width’ radio button in Step 1, on the other hand, then Step 2 lets you specify widths for each column.

You can introduce a new column break in the preview window by simply clicking at the appropriate point on the scale.

A line with an arrow should appear to represent the column break.

Line represents the line break

Place line breaks wherever you need to in the preview window.

If you want to move a line break, simply drag it across. If you want to remove a line, simply double-click on it.

Step 3 of 3

This lets you specify the data format for each column.

You can specify if you want a column to remain in the default format set by the Text Import Wizard or if you want to set the format to be General, Text, or Date

Step 3 settings for text import wizard

Simply select a column from the preview window and select the format you want.

If you want to remove a selected column, select the last radio button option (which says ‘Do not import column‘).

The Advanced button in this step opens the Advanced Text Import Settings dialog box. 

Advanced Text Import Settings dialog box

This dialog box lets you specify advanced formatting options.

For example, you can use the Advanced Text Import Settings to specify what decimal or thousands separators have been used in the text file, so that they can be made to match your computer’s regional settings.

Once you’re done providing all the settings for your imported text data, click on the Finish button.

Finish importing text file into Excel

This will open the Import Data dialog box.

Import Data dialog box

In this box, you can select where you want your text file’s data imported.

If you want to import it into the existing worksheet, you can select or type in a reference to the cell where you want Excel to start displaying the imported data.

If you want to open it in a new worksheet, however, then select the radio button next to ‘New Worksheet’.

Click OK.

Your text file should now get imported to your selected location in Excel, with the format settings that you had specified in the Text Import Wizard.

Imported data opened in Excel
Also read: How to Open XML Files in Excel?

Method 2: Opening a Text File Directly in Excel

You can also choose to simply open the text file directly in Excel.

While opening, Excel recognizes a text file and automatically converts it into a format that can be displayed in a spreadsheet. 

All you need to do is click on the File tab, select Open and then browse and select the text file that you want to open.

One issue that you are likely to face when trying to open a text file directly in Excel is trying to locate the file in the folder.

This is because Excel’s ‘Open File’ dialog box, by default, filters, and displays only Excel files like those with extensions ‘.xls’, ‘.xlsx’, etc.

It also displays CSV files, if your computer is set up to use Excel as the default application to open CSV files.

So if you don’t see your required text file in the folder when trying to open it in Excel, simply select ‘All Files’ from the ‘File Types’ drop-down, as shown below:

Select the file type from the drop down

This will display the Text Import Wizard from where you can set up how you want your Text file’s data to be displayed in Excel (as shown in method 1).

Text Import Wizard

You should now see your text file converted and displayed in Excel.  

Final data in Excel

Once the file opens, if you still find some of the columns (or individual cells) not converted to your required format, you can convert them manually.

While this method to open the Text file directly in Excel works well, the benefit of using the first method (using Text Import Wizard) allows you to make some adjustments even before getting the data in Excel.

In this tutorial, we showed you two ways to convert and open a Text file in Excel.

A third method could be by using online tools like Online2pdf, but we did not dwell too much on this because Excel’s Text Import Wizard provides much more flexibility, allowing you to adjust your data, and format them exactly how you want them.

We hope this tutorial was helpful for you.

Other Excel tutorials you may also like:

  • How to Convert a CSV File to Excel?
  • How to Open VCF File in Excel?
  • How to Open Excel File [xls, xlsx] Online (for FREE)
  • Why does Excel Open on Startup (and How to Stop it)
  • How to Make Excel File Read Only
  • How to Insert an Excel file into MS Word
  • How to Save Selection in Excel as PDF (3 Easy Methods)
  • How to Merge Two Excel Files?
  • How to Convert PDF to Excel without Software?
  • How to Open DAT Files in Excel?

Понравилась статья? Поделить с друзьями:
  • Import data from excel to sql server wizard
  • Import data from excel to python
  • Import data from excel to excel vba
  • Import data from excel into к
  • Import data from excel file to excel file