How to Convert TXT to CSV (Delimited Text, Step by Step)
A .txt file is just plain text, and many exports from banks, legacy systems and databases
use it to carry a table. This guide explains how to read the structure correctly and turn it into a
proper CSV rather than relying on a file extension change.
What Is a TXT Data File?
In a data context, a TXT file usually holds rows of records separated by line breaks, with individual fields split by a repeated character. The file itself does not declare the layout, so the first job is always to inspect the contents. If the separator is a tab, the same data is often called a TSV — you can read more about that format in the guide on what a TSV file is.
Identify the Delimiter First
Open the file in a text editor and look at the first few rows. The delimiter is the character that appears in the same columns on every line:
- Comma (
,) — already CSV-shaped once quoting is correct. - Tab — wide, even gaps; technically a TSV.
- Pipe (
|) — common in database and mainframe exports. - Semicolon (
;) — frequent in regional spreadsheet exports.
Count the separators on a few rows. Healthy rows should have the same number of fields; a changing count is an early warning of an embedded separator or a broken line.
Why Renaming the File Is Not Enough
Changing the suffix from .txt to .csv only relabels the file. If the fields are
separated by tabs or pipes, a spreadsheet reading it as comma-separated data will place each entire line
in one column. The actual characters inside the file have to be normalized, which is what the methods
below do.
Convert TXT to CSV Manually
- Make a copy of the original file so the source stays untouched.
- Open a spreadsheet and use its import option (in Excel, Data → From Text/CSV; in Google Sheets, File → Import).
- Choose the delimiter you identified and confirm the preview shows separate columns.
- Set the encoding to UTF-8 if special characters look wrong.
- Export the result as a comma-separated CSV.
This is the safest route for a one-off file because the preview lets you catch a wrong delimiter before saving.
Convert With a Short Script
For large files or repeated conversions, a script is more reliable. In Python, the built-in reader and writer handle the delimiter and quoting for you:
import csv
with open('input.txt', newline='', encoding='utf-8') as src, \
open('output.csv', 'w', newline='', encoding='utf-8') as dst:
reader = csv.reader(src, delimiter='\t') # use '|' or ';' as needed
writer = csv.writer(dst)
writer.writerows(reader) Change the delimiter to match your file. The writer automatically adds quotes around any field that contains a comma, so you do not have to manage that by hand.
Quoting, Encoding and Other Pitfalls
- Embedded commas or line breaks: wrap the whole field in double quotes.
- Double quotes inside data: escape them by doubling, as in
"He said ""hi""". - Leading zeros (e.g. postal codes) can be dropped by spreadsheets; keep them as text on import.
- Mixed line endings from older systems can create blank rows; normalize them to standard line breaks.
What to Do With the CSV Next
Once the rows are consistent, the CSV opens cleanly in Excel, Google Sheets and accounting software. If you need to move that data into a financial format, the same local engine can take CSV and produce QFX, OFX, QBO or IIF. For the comparison of tab- versus comma-separated output, see how QIF and CSV differ.
Frequently Asked Questions
Is a TXT file the same as a CSV?›
No. A TXT file can contain any plain text, while a CSV is specifically a table where fields are separated by commas and rows by line breaks. A TXT file becomes a CSV only when its contents follow the comma-separated structure, not because you change the extension.
How do I find the delimiter in my TXT file?›
Open the first few lines and look for the character that repeats in the same position on every row. Common delimiters are commas, tabs, the pipe character (|) and semicolons. If columns line up with wide gaps, it is usually a tab; a TSV file is simply tab-separated text.
Can I just rename .txt to .csv?›
Only if the text inside is already comma-separated and correctly quoted. Renaming does not convert tabs or pipes into commas, so a spreadsheet would then dump every row into a single column.
What if a field contains a comma?›
That field must be wrapped in double quotes so the comma is not mistaken for a separator. If the field itself contains a double quote, escape it by doubling the quote ("") inside the quoted field.
Which encoding should I use?›
Save the output as UTF-8 where possible, especially if the data contains non-English characters or currency symbols. This keeps special characters intact when the CSV is opened in Excel or Google Sheets.
Do I need special software?›
No. A spreadsheet such as Excel or Google Sheets can import the text and export a CSV, and a short Python or Node script can do the same for large or repeated files. The conversion runs on your own device.
Prefer One-Click Conversions?
Install the free FinFormats Chrome extension. Everything still runs locally on your device — no upload, no sign-up, no watermark.
Get it on the Chrome Web Store