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.
Note: The Text Import Wizard is a legacy feature that continues to be supported for back-compatibility. As an alternative, you can import a text file by connecting to it with Power Query.
Go to the Data tab > Get External Data > From 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.
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:
-
Click File > Options > Data.
-
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.
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.
No comments:
Post a Comment