How to convert TXT to Excel

Table of Contents

How to convert TXT to Excel

Text files are a common export format used across many industries — from legacy ERP systems and logging tools to simple text-based data apps. They’re lightweight, easy to generate, and universally readable. But for analysis, reporting, or even basic sorting, raw .txt files can be difficult to work with. Converting a TXT file into a structured spreadsheet lets you filter, format, visualise, and validate data far more efficiently.

When should you convert a text file to Excel?

Text files (.txt) are usually unstructured or loosely structured, often separated by tabs, spaces, or pipes. Converting a text document to Excel allows you to:
  • Sort and filter the data easily
  • Use formulas, PivotTables, or conditional formatting
  • Export clean .xlsx or .csv files for further use
  • Automate reporting or reconciliation workflows

Understanding TXT file structures

Most TXT files contain one of the following formats:
  • Delimited files: data separated by a character (e.g., comma, tab, pipe)
  • Fixed-width files: each field has a fixed character width (common in legacy systems)
  • Freeform text: no consistent structure; may require cleanup
Identify the structure so you can apply the correct delimiter or formatting rules during import.

Method 1: Open the text file directly in Excel

Excel has a built-in import wizard that activates when opening a .txt file directly.

Steps

  1. Open Excel
  2. Go to File > Open > Browse and select your .txt file
  3. The Text Import Wizard appears
  4. Choose Delimited or Fixed Width
  5. Select your delimiter (e.g., tab, comma, space)
  6. Format column data types as needed

Best for

  • Small, well-organised files
  • One-off tasks
  • Quick previews of exported logs or reports

Method 2: Use the import feature in Excel

For more control over types and delimiters, use Excel’s built-in import workflow.

Steps

  1. Open a blank workbook
  2. Click the Data tab
  3. Choose Get Data (or Get External Data) > From Text/CSV (or From Text)
  4. Select your .txt file
  5. In the wizard, define delimiters and set each column’s data type
  6. Load the data into your sheet
This approach lets you preview how Excel will interpret the file before loading it.

Method 3: Convert in Notepad and save as CSV

If your TXT is consistently delimited, you can prep it in a text editor like Notepad.

Steps

  1. Open the .txt file in Notepad
  2. Replace tabs or pipes with commas (Edit > Replace)
  3. Save with a .csv extension
  4. Open the file in Excel
This creates a structured CSV that Excel opens natively — handy if a system only exports TXT.

Method 4: Use Python to automate conversion

For recurring or large-scale tasks, scripting is fast and reliable. Python’s pandas library makes this simple.

Example script

import pandas as pd

# Load the text file (tab-delimited)
df = pd.read_table('your_file.txt')

# Export to Excel
df.to_excel('output.xlsx', index=False)

Setup

pip install pandas openpyxl
Automate weekly reports, integrate into ETL workflows, and ensure consistency across datasets.

Tips for structuring data before import

  • Use a consistent delimiter (comma, tab, pipe)
  • Avoid blank rows or irregular spacing
  • Ensure every row has the same number of columns
  • Remove unnecessary special characters or stray quotes
  • Save the file in UTF-8 encoding to avoid garbled symbols

What to do when Excel misreads your TXT file

Common issues:
  • Dates convert incorrectly (e.g., 01/03 becomes a calendar date)
  • Numbers lose leading zeros (postcodes, SKUs, phone numbers)
  • Line breaks create extra rows
  • Multi-word strings split by spaces or commas
Fixes:
  • In the Text Import Wizard, explicitly set column types (use Text for IDs)
  • Wrap data that includes commas or line breaks in quotes
  • Inspect raw structure in Notepad or VS Code
These steps help maintain data integrity during import.

TXT vs CSV vs Excel: which format suits your needs?

Format Structure Best for
TXT Raw or loosely structured Log files, data exports, reports
CSV Flat and structured System imports/exports, databases
XLSX Fully formatted Dashboards, analysis, reports, charts
If your file is already .csv, import CSV data into Excel directly.

Real-world use cases: where TXT → Excel matters

  • Customer support reports from legacy tools
  • Healthcare records in fixed-width format
  • Government open-data text dumps
  • Developer/event logs needing filtering or sorting
  • Inventory exports from older warehouse systems (pipe/tab-delimited)

How to choose the right method

Use case Best method
One-time conversion Open directly in Excel or use Notepad
Repeated formatting needs Use the Import feature
Large files or automation Python with pandas
Unstructured or messy files Clean in a text editor first

Conclusion

Whether you’re working with reports, system logs, or legacy exports, converting text files into Excel makes data easier to interpret and act on. Excel offers multiple ways to import and clean text-based data, from simple manual steps to advanced automation. If you regularly receive text files for analysis, learning to convert TXT to Excel efficiently will save hours of manual cleanup.

Check out our latest resources

Sellermania

2Plus1Ads

Scroll to Top