Skip to main content

clean CSVs

Project description

clean your CSVs!

This command line tool cleans CSV files by:

  1. converting encoding to utf-8
  2. detecting the delimiter and safely converting it to a comma
  3. casting all variables to json form, i.e. integers, floats, booleans, string or null.
  • install pip install csv-bleach
  • and run like python -m csv_bleach my-data.csv

The only option is the output file name, by default it will be your original file name with .scsv extension.

You will now be able to parse your CSV safely with a simple script like:

import json


def parse_row(text):
    return json.loads(f"[{text}]")

def parse_file(file):
    rows = map(parse_row, file)
    header = next(rows)
    for row in rows:
        yield dict(zip(header, row))


with open("my-data.scsv") as f:
    for item in parse_file(f):
        print(item)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

csv_bleach-2.4.0.tar.gz (4.3 kB view hashes)

Uploaded Source

Built Distribution

csv_bleach-2.4.0-py3-none-any.whl (6.4 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page