Align columns of data read from standard input
Project description
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
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 tidycols-0.1.0.tar.gz.
File metadata
- Download URL: tidycols-0.1.0.tar.gz
- Upload date:
- Size: 4.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
00551e91f57187ac5b24185acdce72dc7e3b383510aab92bc853beef224af3e1
|
|
| MD5 |
c1944d1442070e9119882edbfd0f42c3
|
|
| BLAKE2b-256 |
defda63a94501fa1c4b667f0b559c468ee4adf27ef30522c4c1750d923694a53
|
File details
Details for the file tidycols-0.1.0-py3-none-any.whl.
File metadata
- Download URL: tidycols-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d68bf8b1499b591dc4b178d3080c1aee56d7edaccb0e7da4631cf347762e69b3
|
|
| MD5 |
b29a9676dc72a0a63c2ad7b4e1caeae3
|
|
| BLAKE2b-256 |
7d5a7acc1d0a6cac3099c4c375f3509585df82642002a15d9cc4dfaf25d8bfb3
|