Skip to content
Free · Runs in your browser

TXT to CSV converter

Turn a text file into a CSV. The columns are found for you, whether the file uses tabs, pipes or spaces, and it never leaves your browser.

Works with
TXTTSVDATCSVXLSX
Opens inExcelGoogle Sheets

Drop a text file here

TXT, TSV, DAT or CSV, up to 100 MB. It stays on your computer.

  • No sign-up
  • Nothing uploaded
  • Columns found for you
  • Arla Foods logo
  • Bacardi logo
  • British American Tobacco logo
  • Everest Detection logo
  • Golden Acre logo
  • Handlangers logo
  • Inspired Learning Group logo
  • Kantar logo
  • MUFG logo
  • NielsenIQ logo
  • PTI Digital logo
  • RethinkFirst logo
  • Starbucks logo
  • The Specialist Works logo
What you get

A CSV with the columns where they belong.

  • Your file stays on your computer

    The text is read and the CSV is written in your browser. Nothing is sent to Mammoth or anyone else.

  • Lined-up reports split into columns

    A column starts where every line has a gap of two or more spaces, so a name like Ana Costa stays in one cell.

  • Tabs, pipes and commas found for you

    The separator is picked from the first lines of the file. If it guessed wrong, change it in one click.

How it works

How to convert TXT to CSV

The first line gives the column names. Dashed lines and table borders are left out, and each value is trimmed of the spaces that padded it.

  1. 1

    Add your text file

    Drop a .txt, .tsv or .dat file on the box, choose one, or paste the text in.

  2. 2

    Check the columns

    A preview shows the table. Change how the columns are split if you need to.

  3. 3

    Download

    Save the CSV, with commas, semicolons or tabs, or save it as an Excel file.

Your options

Other ways to do it

Excel and Python can both turn a text file into a CSV. The difference is how much you set by hand.

  • Excel's Text Import Wizard

    A one-off file on a computer with Excel

    • Finds the columns for youNo
    • Drops dashed rule linesNo
    • Keeps leading zerosPartly
    • No software to installNo
  • Python with pandas

    A script that runs every day

    • Finds the columns for youPartly
    • Drops dashed rule linesNo
    • Keeps leading zerosPartly
    • No software to installNo
  • This page

    This converter

    A clean CSV in one step

    • Finds the columns for youYes
    • Drops dashed rule linesYes
    • Keeps leading zerosYes
    • No software to installYes
Other ways

How to convert a text file to CSV in Excel or Python

Excel's Text Import Wizard asks you how the file is split, then Save As writes the CSV. In Python, pandas reads a lined-up file with read_fwf.

  1. 1

    In Excel, go to File > Open, set the file type to Text Files, and pick your .txt file. The Text Import Wizard opens.

  2. 2

    Choose Delimited if a tab or other character sits between the values, or Fixed width if the columns are lined up with spaces.

  3. 3

    Set the separator, or click in the preview to place each column break. Set a column with codes like 00071 to Text.

  4. 4

    Select Finish, then go to File > Save As and pick CSV UTF-8 (Comma delimited).

Want a spreadsheet, not a CSV? The TXT to Excel converter writes an .xlsx straight away.

Python with pandas
import pandas as pd

df = pd.read_fwf("report.txt", dtype=str)
df = df.drop(index=0)  # the ----- line under the header
df.to_csv("report.csv", index=False)

For a file lined up with spaces. pandas reads the dashed line as a row, so it is dropped after reading. Skipping it with skiprows instead makes pandas guess the widths again, and in our test that split O'Neill & Co into two columns. For a tab file, use pd.read_csv("report.txt", sep="\t").

Your file stays private

The converter runs inside this page. Your text file is read and turned into a CSV on your computer, and nothing is sent to Mammoth. That makes it safe for exports with customer or payroll data in them.

How we handle your data

Once the page has loaded, it works with your internet switched off.

Every month

Getting the same export every week?

Mammoth can take it from there. Put each week's CSV in a folder and the rows are added to one table, ready to download as CSV or Excel.

Try Mammoth free

Weekly reports

Week 43sales-w43.csv
Week 44sales-w44.csv
Week 45sales-w45.csv
DriveDropboxOneDriveSFTP
All weeksUp to date
Oct 21Ana Costa129.50
Oct 23Ben Ellis48.00
Oct 28Dev Patel75.90
Nov 04Chloé Martin310.25
Nov 06O'Neill & Co1,200.00

Illustration. Every new file in the folder is added to the same table.

Questions

TXT to CSV questions

Is my text file uploaded anywhere?
No. The page reads the file and writes the CSV inside your browser. Once the page has loaded, it works with your internet switched off.
How does it know where the columns are?
It looks at the first 200 lines. If a tab, pipe, comma or semicolon splits every line the same way, that is the separator. If the lines are padded with spaces instead, a column starts wherever every line has a gap of two or more spaces in the same place. You can change the choice in one click.
My report has spaces inside values, like a customer name. Does that break it?
No. A single space, as in Ana Costa, never splits a column when the file is lined up. It takes a gap of two or more spaces, in the same place on every line.
What happens to dashed lines and table borders?
Lines made only of dashes, equals signs or plus signs are dropped, and so are the outer | borders of a database table and a closing (3 rows) line. Only the header and the data are kept.
Can it convert a TSV file to CSV?
Yes. A TSV file is a text file with tabs between the values. Drop it on the box and the tabs are found for you, then download a comma-separated CSV.
My file has no header line. What then?
Switch off First line is the header. The columns are then named column_1, column_2 and so on, and the first line is kept as data.
Will accents come through?
Yes. The file is read as UTF-8, as UTF-16 when it starts with a byte-order mark, and as Windows-1252 otherwise. The CSV is written as UTF-8.
Is it free?
Yes, with no account and no email.