tidy-columns
Align columns of data read from standard input and write the formatted result to standard output.
Note that all data is read into RAM, so this may not work on very large inputs.
Usage
tidy-columns.py [--defaultAlignment R|L] [--alignment alignment] [--addCommas] [--separator X] < input > output
where alignment is a string of L and R characters, and X is any string.
Examples
Suppose we have this input data in a file called /tmp/data:
01-1-bursa 1288703
02-1-cecal-tonsil 1199476
03-1-spleen 1095290
04-1-thymus 1950795
05-1-cloaca-swab 1196991
06-1-oropharynx-swab 934725
07-2-bursa 1469444
08-2-cecal-tonsil 2172147
09-2-spleen 2188220
10-2-thymus -939127
11-2-cloaca-swab 1554
12-2-oropharynx-swab 12653204
we can format it nicely via:
$ tidy-columns.py < /tmp/data
01-1-bursa 1288703
02-1-cecal-tonsil 1199476
03-1-spleen 1095290
04-1-thymus 1950795
05-1-cloaca-swab 1196991
06-1-oropharynx-swab 934725
07-2-bursa 1469444
08-2-cecal-tonsil 2172147
09-2-spleen 2188220
10-2-thymus -939127
11-2-cloaca-swab 1554
12-2-oropharynx-swab 12653204
To align the second column to the right:
$ tidy-columns.py --alignment LR < /tmp/data
01-1-bursa 1288703
02-1-cecal-tonsil 1199476
03-1-spleen 1095290
04-1-thymus 1950795
05-1-cloaca-swab 1196991
06-1-oropharynx-swab 934725
07-2-bursa 1469444
08-2-cecal-tonsil 2172147
09-2-spleen 2188220
10-2-thymus -939127
11-2-cloaca-swab 1554
12-2-oropharynx-swab 12653204
To change the default alignment to right:
$ tidy-columns.py --defaultAlignment R < /tmp/data
01-1-bursa 1288703
02-1-cecal-tonsil 1199476
03-1-spleen 1095290
04-1-thymus 1950795
05-1-cloaca-swab 1196991
06-1-oropharynx-swab 934725
07-2-bursa 1469444
08-2-cecal-tonsil 2172147
09-2-spleen 2188220
10-2-thymus -939127
11-2-cloaca-swab 1554
12-2-oropharynx-swab 12653204
Or right then left alignment:
$ tidy-columns.py --alignment RL < /tmp/data
01-1-bursa 1288703
02-1-cecal-tonsil 1199476
03-1-spleen 1095290
04-1-thymus 1950795
05-1-cloaca-swab 1196991
06-1-oropharynx-swab 934725
07-2-bursa 1469444
08-2-cecal-tonsil 2172147
09-2-spleen 2188220
10-2-thymus -939127
11-2-cloaca-swab 1554
12-2-oropharynx-swab 12653204
Add commas to (integer) numbers:
$ tidy-columns.py --alignment LR --addCommas < /tmp/data
01-1-bursa 1,288,703
02-1-cecal-tonsil 1,199,476
03-1-spleen 1,095,290
04-1-thymus 1,950,795
05-1-cloaca-swab 1,196,991
06-1-oropharynx-swab 934,725
07-2-bursa 1,469,444
08-2-cecal-tonsil 2,172,147
09-2-spleen 2,188,220
10-2-thymus -939,127
11-2-cloaca-swab 1,554
12-2-oropharynx-swab 12,653,204
Change the field separator to ' | ':
$ tidy-columns.py --alignment LR --addCommas --separator ' | ' < /tmp/data
01-1-bursa | 1,288,703
02-1-cecal-tonsil | 1,199,476
03-1-spleen | 1,095,290
04-1-thymus | 1,950,795
05-1-cloaca-swab | 1,196,991
06-1-oropharynx-swab | 934,725
07-2-bursa | 1,469,444
08-2-cecal-tonsil | 2,172,147
09-2-spleen | 2,188,220
10-2-thymus | -939,127
11-2-cloaca-swab | 1,554
12-2-oropharynx-swab | 12,653,204
Metadata
Release files for tidycols 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| tidycols-0.1.0.tar.gz | 4.2 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| tidycols-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 8.9 kB
Release files / tidycols-0.1.0.tar.gz
| Download URL | tidycols-0.1.0.tar.gz |
|---|---|
| Size | 4.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
00551e91f57187ac5b24185acdce72dc7e3b383510aab92bc853beef224af3e1
|
|
BLAKE2b-256 checksum How to use checksums |
defda63a94501fa1c4b667f0b559c468ee4adf27ef30522c4c1750d923694a53
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.6
|
Release files / tidycols-0.1.0-py3-none-any.whl
| Download URL | tidycols-0.1.0-py3-none-any.whl |
|---|---|
| Size | 4.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d68bf8b1499b591dc4b178d3080c1aee56d7edaccb0e7da4631cf347762e69b3
|
|
BLAKE2b-256 checksum How to use checksums |
7d5a7acc1d0a6cac3099c4c375f3509585df82642002a15d9cc4dfaf25d8bfb3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.6
|
Security for tidycols 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.