Skip to content

About

CLI tool that accepts messy CSV files. Generates a pre_report and post_report. Performs minor cleaning such as whitespace trimming, null normalization, duplicate removal, and detects formatting issues like mixed date formats, mismatched row lengths, and string-based null variants.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

45 Commits

Folders and files

Repository files navigation

CSV Cleaner

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.

What it cleans up

  • Trims extra spaces around values.
  • Standardizes "empty" values — things like NULL, N/A, na, -, ?, and undefined all 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.

What it flags (without changing)

  • Mixed date formats inside the same column (for example, some rows using 2024-01-15 and others using 01/15/2024).
  • Rows that were the wrong length in the original file.

Setup

You'll need Python 3. From inside the project folder:

pip install .

This installs the tool along with what it needs (pandas and tabulate).

How to use it

Point it at a CSV file:

python main.py yourfile.csv

By 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.csv

To see the full before-and-after report printed in the terminal, add --show-output.

Options

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.

Examples

The csv_tests folder has sample messy files (and their cleaned versions) you can try it on, for examlple, dirty_kitchen_sink.csv.

Tests

The project includes a test suite. To run it:

pytest

About

CLI tool that accepts messy CSV files. Generates a pre_report and post_report. Performs minor cleaning such as whitespace trimming, null normalization, duplicate removal, and detects formatting issues like mixed date formats, mismatched row lengths, and string-based null variants.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages