Skip to main content

csv-from-mbox

Turn an .mbox export into a CSV you can actually open in a spreadsheet.

You know the drill: Google Takeout hands you a two-gigabyte All mail Including Spam and Trash.mbox, and every tool that can open it wants to be an email client about it. This one does not. One Python file, standard library only, two modes, done.

What it does

Messages mode (default): one row per email.

date from_name from_email to cc subject body
2026-08-28T10:00:00+01:00 Ash Ketchum ash@pallet.town misty@cerulean.gym Gym battle I choose you!

Bodies prefer text/plain, HTML-only emails get their tags stripped, attachments are ignored, encoded headers (=?utf-8?q?Pok=C3=A9mon?=) are decoded, and dates come out ISO 8601 so your spreadsheet sorts them properly.

Addresses mode (--addresses): the original party trick. Every unique sender address, lowercased, deduplicated and sorted, with automated senders (noreply, no-reply, do-not-reply, do_not_reply, donotreply) filtered out. Great for finding out who actually writes to you.

Install

From PyPI:

pip install csv-from-mbox

Or run it without installing anything, via uv or pipx:

uvx csv-from-mbox mail.mbox
pipx run csv-from-mbox mail.mbox

Or clone it and run the file, there are no dependencies to install:

python3 csv_from_mbox.py mail.mbox

Use

csv-from-mbox mail.mbox                # messages.csv with everything
csv-from-mbox mail.mbox --no-body      # metadata only, much smaller file
csv-from-mbox mail.mbox --addresses    # emails.csv with unique senders
csv-from-mbox mail.mbox -o ~/Desktop   # choose where it goes
csv-from-mbox mail.mbox -o - | head    # stream CSV to stdout, chatter on stderr
csv-from-mbox                          # no arguments? it will ask nicely

Being a well-behaved unix citizen, -o - pipes straight into xsv, duckdb, grep and friends:

csv-from-mbox mail.mbox -o - | duckdb -c "SELECT from_email, count(*) FROM read_csv('/dev/stdin') GROUP BY 1 ORDER BY 2 DESC LIMIT 10"

Test

python3 -m unittest discover tests

Requirements

Python 3.9 or newer. Nothing else. That is the whole point.

License

MIT.

Release files for csv-from-mbox 0.5.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for csv-from-mbox 0.5.1
File Size Uploaded
csv_from_mbox-0.5.1.tar.gz 5.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for csv-from-mbox 0.5.1
File Interpreter ABI Platform
csv_from_mbox-0.5.1-py3-none-any.whl Python 3 none any Details

Total release size: 12.1 kB

Release files / csv_from_mbox-0.5.1.tar.gz

Download URL csv_from_mbox-0.5.1.tar.gz
Size 5.5 kB
Tags Source
SHA-256 checksum
How to use checksums
545eb6eb212ab986d1e71daca881f8c5a13e17421e42fc78c949e6ec9930cae3
BLAKE2b-256 checksum
How to use checksums
a7b262c510aa401bbfb82e5fe8b411ca8c21b778983d2be11e4045295576b7c3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.27 {"installer":{"name":"uv","version":"0.9.27","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / csv_from_mbox-0.5.1-py3-none-any.whl

Download URL csv_from_mbox-0.5.1-py3-none-any.whl
Size 6.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4380839b10a144e7fe77028614f76103ecf3fdfe1a0e76d6e3d51ce77f07046f
BLAKE2b-256 checksum
How to use checksums
9795c28d6af084df86047b3a5a1524b75224c95e4f06bc4cf3e38880abc57634
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.27 {"installer":{"name":"uv","version":"0.9.27","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release history Release notifications | RSS feed

This release

0.5.1 This release

2 release files

0.5.0

2 release files

0.4.5

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page