Import a structured text file to an Excel spreadsheet
- Files with fixed-width columns (see how to import data from this type of text files),
- Comma-separated files (.csv),
- Tab-separated files (.txt).
To import data from a text file, do the following:
1. On the File tab, click Open (or click Ctrl+O).
2. On the Open pane, click the Browse button:
3. On the Open dialog box:
- Select the path to the text file you want to import,
- From the File Type dropdown list, select All Files or Text Files:
- Click the Open button.
Note: After clicking the Open button, some comma-separated files (.csv) open automatically.
4. In the Text Import Wizard – Step 1 of 3 dialog box:
4.1. If you do not see the delimiters, and it seems that data starts at fixed positions in the file, you can change the Original data type by selecting Fixed width instead of Delimited (see the steps on how to import data from this type of files):
4.2. You can change the File origin to use another encoding to display the data (you need to know the character encoding for the data or try other encodings until you see the correct data in the preview section):
4.3. Click the Next > button.
5. In the Text Import Wizard – Step 2 of 3 dialog box:
5.1. In the Delimiters group, choose the correct delimiter for the data (by default, the Tab delimiter is used, but standard formats use commas or semicolons):
Note: Even if you are pretty sure about the delimiter, you need to change it if you see incorrect data in the Data preview area.
5.2. Click the Next > button.
6. In the Text Import Wizard – Step 3 of 3 dialog box:
6.1. Select the column and, in the Column data format group, the appropriate data format for this column:
- You can skip this step and format columns after importing.
- You can click the Advanced... button to select the correct Decimal separator and Thousands separator (see how to change the used by default decimal symbol and digit grouping symbol):
- You can skip some columns for importing by selecting the Do not import column (skip) in the Column data format group (the second column Session in the previous example).
6.2. Repeat the previous step for all columns you want to import and click Finish.
Excel imports all the data you selected:
See also this tip in French: Comment importer des données à partir d’un fichier texte structuré.