A command-line tool that takes a messy CSV file and gives you back a cleaned version. It shows you a quick report of what the file looked like before, cleans it up, and then shows you what it changed.
- Trims extra spaces around values.
- Standardizes "empty" values — things like
NULL,N/A,na,-,?, andundefinedall become blank, so missing data looks consistent. - Removes duplicate rows (including ones that only differ by capitalization).
- Removes rows and columns that are completely empty.
- Trims rows that have more values than there are columns.
- Mixed date formats inside the same column (for example, some rows using
2024-01-15and others using01/15/2024). - Rows that were the wrong length in the original file.
You'll need Python 3. From inside the project folder:
pip install .This installs the tool along with what it needs (pandas and tabulate).
Point it at a CSV file:
python main.py yourfile.csvBy default it saves the cleaned file next to the original with _cleaned added
to the name (for example, yourfile_cleaned.csv).
To choose where the cleaned file goes:
python main.py yourfile.csv -o cleaned.csvTo see the full before-and-after report printed in the terminal, add
--show-output.
| Option | What it does |
|---|---|
-o, --output |
Choose the name/location of the cleaned file. |
--no-duplicates |
Don't remove duplicate rows. |
--no-empty-rows |
Don't remove empty rows. |
--keep-nulls |
Leave "empty" values as they are. |
--show-output |
Print the before/after report in the terminal. |
The csv_tests folder has sample messy files (and their cleaned versions) you
can try it on, for examlple, dirty_kitchen_sink.csv.
The project includes a test suite. To run it:
pytest