A command line tool for CSV file processing
Project description
csv_fix
Instruction
This script uses state machine to fix maleformed csv file.
Usage: csv_fix.py [Options] <filename>
Options and arguments:
[-h/--help]: Show this message.
[-s]: Define sperator. Defaults to comma.
[-q]: Define text qualifier. Defaults to auto detect.
[-t]: Trim white space at the beginning and end of each field. Defaults to double quote.
[-z]: (Being constructed) Specify timezone for time fields. Defaults to server timezone. Can also be Asia/Chongqing etc.
For standard timezone names, refer to: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
[-k]: Skip errors and continue parsing following lines.
<filename>: csv file name.
Examples
# Input from stdin
cat test_case.csv | csv_fix
# Input from file
csv_fix -t test_case.csv
The processed output will be written to stdout.
Features
Fix Malformed CSV
Try to fix the format whenever possible. You can find test cases in ./tests/.
The script follow this state machine to fix possible errors:
Trim White Space
For fields that begin/end with white space can be stripped by specifying -t.
echo -n ' red, yellow,green ,"red "' | csv_fix -t
# Output: "red","yellow","green","red"
Customize Seperator
Seperator can be customized. Specify seperator by -s.
echo -n 'A 27" monitor|"This should be good.|"|"' | csv_fix -s '|'
# Output: "A 27"" monitor"|"This should be good.|"|""
Customize Qualifier
Qualifier can be customized. Specify qualifier by -q.
echo -n "'hello, what's up!','Not bad!'" | csv_fix -q "'"
# Output 'hello, what''s up!','Not bad!'
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
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_fix-0.3.0.tar.gz.
File metadata
- Download URL: csv_fix-0.3.0.tar.gz
- Upload date:
- Size: 10.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
87b4c6a619b648aafdaa4a4a17fa176d5b88def5f825b76fdfbf0c7102b50935
|
|
| MD5 |
bbedd462b1383e77c53c461c1675059f
|
|
| BLAKE2b-256 |
83c702e7aeb658e62857df4a54892c1fca88a8b8be669b5cf1955f7a11a518cd
|
Provenance
The following attestation bundles were made for csv_fix-0.3.0.tar.gz:
Publisher:
publish.yml on zhangyaoxing/csv_fix
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
csv_fix-0.3.0.tar.gz -
Subject digest:
87b4c6a619b648aafdaa4a4a17fa176d5b88def5f825b76fdfbf0c7102b50935 - Sigstore transparency entry: 833778420
- Sigstore integration time:
-
Permalink:
zhangyaoxing/csv_fix@76811a64ddf5f285fd77dd584fe55ef083bc6a9f -
Branch / Tag:
refs/tags/v0.3 - Owner: https://github.com/zhangyaoxing
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@76811a64ddf5f285fd77dd584fe55ef083bc6a9f -
Trigger Event:
release
-
Statement type:
File details
Details for the file csv_fix-0.3.0-py3-none-any.whl.
File metadata
- Download URL: csv_fix-0.3.0-py3-none-any.whl
- Upload date:
- Size: 9.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
00b54b4d415bf34c42411532ae9882894bd4e5a10647bfb8bb989aae15aefbd7
|
|
| MD5 |
91d420a22c4201f5021975d9699e685d
|
|
| BLAKE2b-256 |
b4da98d8d25fb5c15045289e8878b1bee9c4e52afbd4c38ef5f586ecbc676a3c
|
Provenance
The following attestation bundles were made for csv_fix-0.3.0-py3-none-any.whl:
Publisher:
publish.yml on zhangyaoxing/csv_fix
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
csv_fix-0.3.0-py3-none-any.whl -
Subject digest:
00b54b4d415bf34c42411532ae9882894bd4e5a10647bfb8bb989aae15aefbd7 - Sigstore transparency entry: 833778421
- Sigstore integration time:
-
Permalink:
zhangyaoxing/csv_fix@76811a64ddf5f285fd77dd584fe55ef083bc6a9f -
Branch / Tag:
refs/tags/v0.3 - Owner: https://github.com/zhangyaoxing
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@76811a64ddf5f285fd77dd584fe55ef083bc6a9f -
Trigger Event:
release
-
Statement type: