Skip to main content

clean CSVs

Project description

clean your CSVs!

This command line tool cleans CSV files by:

  1. detecting the encoding and converting it 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 poetry run 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-0.1.2.tar.gz (5.0 kB view details)

Uploaded Source

Built Distribution

csv_bleach-0.1.2-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

Details for the file csv_bleach-0.1.2.tar.gz.

File metadata

  • Download URL: csv_bleach-0.1.2.tar.gz
  • Upload date:
  • Size: 5.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.2 CPython/3.11.0 Linux/5.15.0-1031-azure

File hashes

Hashes for csv_bleach-0.1.2.tar.gz
Algorithm Hash digest
SHA256 112258a416838d023289e9b34c8df2a755c685c602fe0aaf693db2ca10cf1c1e
MD5 d9c424dcaf8a56a2fa567f2dab1a1ce8
BLAKE2b-256 8287c00b942906e0ba0e5f2b97a48bc20e421bdcd17db3832c3e171ff15fa7c2

See more details on using hashes here.

File details

Details for the file csv_bleach-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: csv_bleach-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 6.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.2 CPython/3.11.0 Linux/5.15.0-1031-azure

File hashes

Hashes for csv_bleach-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 f8caa366a2c405d0dfe4246fb8154d00bb8bfbcc9c82a7b2c5ba44a402f56c7f
MD5 3a58ed6165f96e00ab81315d77b47a06
BLAKE2b-256 e5a603a46f7036e4c56c0a98f3202c781310ba7b2fdef49876f039f853f66311

See more details on using hashes here.

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