clean CSVs
Project description
clean your CSVs!
This command line tool cleans CSV files by:
- detecting the encoding and converting it to utf-8
- detecting the delimiter and safely converting it to a comma
- casting all variables to json form, i.e. integers, floats, booleans, string or null.
- install
pip install csv-bleach
- and run like
python -m run 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-0.2.3.tar.gz
(5.1 kB
view details)
Built Distribution
File details
Details for the file csv_bleach-0.2.3.tar.gz
.
File metadata
- Download URL: csv_bleach-0.2.3.tar.gz
- Upload date:
- Size: 5.1 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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1b14cdf085c252240ccf3fab8d7a396952d492cb3181eb8cdf58ce357c7f778b |
|
MD5 | 976bc39fb0007b317137cc29800a7ef6 |
|
BLAKE2b-256 | 2d470f9e2af34700c2048509dfa4e35706f37de565a456bb2211072eb40a2d03 |
File details
Details for the file csv_bleach-0.2.3-py3-none-any.whl
.
File metadata
- Download URL: csv_bleach-0.2.3-py3-none-any.whl
- Upload date:
- Size: 6.7 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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2e021b2c8142d0b083dbabb7b9b77203e5f4d0e3b10f5cfe11d712a67ecb6de4 |
|
MD5 | 9163f975188407aea5b9e52e497d2237 |
|
BLAKE2b-256 | 29981af97c4e20e22367334a0d0a352a6d2f7035f3df578dcefeecf71ad45f50 |