clean CSVs
Project description
clean your CSVs!
This command line tool cleans CSV files by:
- converting encoding 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 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 details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file csv_bleach-2.4.0.tar.gz.
File metadata
- Download URL: csv_bleach-2.4.0.tar.gz
- Upload date:
- Size: 4.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.11.0 Linux/6.2.0-1018-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
671a2be98925ea08bb3de0656283a8b5c33524fc7a28b6088228d29fcc72ca08
|
|
| MD5 |
1fb09850ad24716f9637ba8b9d5b7090
|
|
| BLAKE2b-256 |
38cbd31492cc98f56492798e390ab003c68457156064e33a2ff916a470a597b5
|
File details
Details for the file csv_bleach-2.4.0-py3-none-any.whl.
File metadata
- Download URL: csv_bleach-2.4.0-py3-none-any.whl
- Upload date:
- Size: 6.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.11.0 Linux/6.2.0-1018-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ff2307c0d14ab9da793ec2f343ca94685ed810f874a815d8b94363426f859296
|
|
| MD5 |
31cc1543eed34c9e0f2337adf2958397
|
|
| BLAKE2b-256 |
4daebeaf3330912c38372ffacd55ed3264147fbd79dbd54cfc1caaa9f1f63b40
|