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.2.0.tar.gz (5.0 kB view details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: csv_bleach-0.2.0.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.2.0.tar.gz
Algorithm Hash digest
SHA256 2eadaf226fc0c4b04d245e1779cf3c7495425b7a4723713940a4656f91249bb2
MD5 a74fac3c2c8032934e36546ffc69e172
BLAKE2b-256 f2c41736786a9d65e538ebbebb3b44f9f1abc3966e277d004e97bd1589f3ec01

See more details on using hashes here.

File details

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

File metadata

  • Download URL: csv_bleach-0.2.0-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.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4779e2109d47f8da6c841c337142adeb0898d8ed19ccf43fe61a128a0f01da44
MD5 ef2fbe411ae0bd0791f735aac7147afd
BLAKE2b-256 d393c1ba1656e5222625d52b7e4e99ec66978f58cbf35b658de742e8024abb4a

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