Skip to content

[from ssv -a] (you knew this one was coming) #18741

Description

@c4lliope

Here's a sample aligned space-seperated value table:

❄ calliope@chesapeake:  …/essay   main $!?⇡   22:49 
➜ df -ahT -t ramfs -t tmpfs

Filesystem     Type   Size  Used Avail Use% Mounted on
tmpfs          tmpfs   24G  6.7M   24G   1% /run
tmpfs          tmpfs   47G  392M   47G   1% /dev/shm
ramfs          ramfs     0     0     0    - /run/keys
none           tmpfs  1.0M     0  1.0M   0% /run/credentials/systemd-journald.service
tmpfs          tmpfs   47G  1.2M   47G   1% /run/wrappers
tmpfs          tmpfs  250M     0  250M   0% /var/lib/incus/devices
tmpfs          tmpfs  100K     0  100K   0% /var/lib/incus/shmounts
tmpfs          tmpfs  100K     0  100K   0% /var/lib/incus/guestapi
tmpfs          tmpfs  9.4G   48K  9.4G   1% /run/user/1000

Here's from_ssv:

❄ calliope@chesapeake:  …/essay   main $!?⇡   22:49 
➜ df -ahT -t ramfs -t tmpfs | from ssv
╭───┬────────────┬───────┬──────┬────────────────────────────╮
│ # │ Filesystem │ Type  │ Size │ Used Avail Use% Mounted on │
├───┼────────────┼───────┼──────┼────────────────────────────┤
│ 0 │ tmpfs      │ tmpfs │ 24G  │ 6.7M                       │
│ 1 │ tmpfs      │ tmpfs │ 47G  │ 386M                       │
│ 2 │ ramfs      │ ramfs │ 0    │ 0                          │
│ 3 │ none       │ tmpfs │ 1.0M │ 0                          │
│ 4 │ tmpfs      │ tmpfs │ 47G  │ 1.2M                       │
│ 5 │ tmpfs      │ tmpfs │ 250M │ 0                          │
│ 6 │ tmpfs      │ tmpfs │ 100K │ 0                          │
│ 7 │ tmpfs      │ tmpfs │ 100K │ 0                          │
│ 8 │ tmpfs      │ tmpfs │ 9.4G │ 48K                        │
╰───┴────────────┴───────┴──────┴────────────────────────────╯

Here's from ssv -a (aligned columns):

❄ calliope@chesapeake:  …/essay   main $!?⇡   22:49 
➜ df -ahT -t ramfs -t tmpfs | from ssv -a
╭───┬────────────┬───────┬──────┬──────────────────────────────────────────────────╮
│ # │ Filesystem │ Type  │ Size │            Used Avail Use% Mounted on            │
├───┼────────────┼───────┼──────┼──────────────────────────────────────────────────┤
│ 0 │ tmpfs      │ tmpfs │ 24G  │ 6.7M   24G   1% /run                             │
│ 1 │ tmpfs      │ tmpfs │ 47G  │ 381M   47G   1% /dev/shm                         │
│ 2 │ ramfs      │ ramfs │ 0    │ 0     0    - /run/keys                           │
│ 3 │ none       │ tmpfs │ 1.0M │ 0  1.0M   0%                                     │
│   │            │       │      │ /run/credentials/systemd-journald.service        │
│ 4 │ tmpfs      │ tmpfs │ 47G  │ 1.2M   47G   1% /run/wrappers                    │
│ 5 │ tmpfs      │ tmpfs │ 250M │ 0  250M   0% /var/lib/incus/devices              │
│ 6 │ tmpfs      │ tmpfs │ 100K │ 0  100K   0% /var/lib/incus/shmounts             │
│ 7 │ tmpfs      │ tmpfs │ 100K │ 0  100K   0% /var/lib/incus/guestapi             │
│ 8 │ tmpfs      │ tmpfs │ 9.4G │ 48K  9.4G   1% /run/user/1000                    │
╰───┴────────────┴───────┴──────┴──────────────────────────────────────────────────╯

Close! Maybe we need a smaller minimum column. 1 space is the only choice that makes sense.

❄ calliope@chesapeake:  …/essay   main $!?⇡   22:49 
➜ df -ahT -t ramfs -t tmpfs | from ssv -a -m 1
╭───┬────────────┬───────┬──────┬──────┬───────┬──────┬──────────┬─────────────────╮
│ # │ Filesystem │ Type  │ Size │ Used │ Avail │ Use% │ Mounted  │       on        │
├───┼────────────┼───────┼──────┼──────┼───────┼──────┼──────────┼─────────────────┤
│ 0 │ tmpfs      │ tmpfs │ 24G  │ 6.7M │ 24G   │ 1%   │ /run     │                 │
│ 1 │ tmpfs      │ tmpfs │ 47G  │ 400M │ 47G   │ 1%   │ /dev/shm │                 │
│ 2 │ ramfs      │ ramfs │ 0    │ 0    │ 0     │ -    │ /run/key │ s               │
│ 3 │ none       │ tmpfs │ 1.0M │ 0    │ 1.0M  │ 0%   │ /run/cre │ dentials/system │
│   │            │       │      │      │       │      │          │ d-journald.serv │
│   │            │       │      │      │       │      │          │ ice             │
│ 4 │ tmpfs      │ tmpfs │ 47G  │ 1.2M │ 47G   │ 1%   │ /run/wra │ ppers           │
│ 5 │ tmpfs      │ tmpfs │ 250M │ 0    │ 250M  │ 0%   │ /var/lib │ /incus/devices  │
│ 6 │ tmpfs      │ tmpfs │ 100K │ 0    │ 100K  │ 0%   │ /var/lib │ /incus/shmounts │
│ 7 │ tmpfs      │ tmpfs │ 100K │ 0    │ 100K  │ 0%   │ /var/lib │ /incus/guestapi │
│ 8 │ tmpfs      │ tmpfs │ 9.4G │ 48K  │ 9.4G  │ 1%   │ /run/use │ r/1000          │
╰───┴────────────┴───────┴──────┴──────┴───────┴──────┴──────────┴─────────────────╯

um. those last two columns were broken up? it's one column. the last one column, "Mounted on", became two columns, simply because the column name had a space. None of the values, file paths, had spaces. Only the header row is used to decide where the column breaks?

Again, to keep you from scrolling, original:

❄ calliope@chesapeake:  …/essay   main $!?⇡   22:49 
➜ df -ahT -t ramfs -t tmpfs

Filesystem     Type   Size  Used Avail Use% Mounted on
tmpfs          tmpfs   24G  6.7M   24G   1% /run
tmpfs          tmpfs   47G  392M   47G   1% /dev/shm
ramfs          ramfs     0     0     0    - /run/keys
none           tmpfs  1.0M     0  1.0M   0% /run/credentials/systemd-journald.service
tmpfs          tmpfs   47G  1.2M   47G   1% /run/wrappers
tmpfs          tmpfs  250M     0  250M   0% /var/lib/incus/devices
tmpfs          tmpfs  100K     0  100K   0% /var/lib/incus/shmounts
tmpfs          tmpfs  100K     0  100K   0% /var/lib/incus/guestapi
tmpfs          tmpfs  9.4G   48K  9.4G   1% /run/user/1000

Because none (not-all) of the file paths have a space separator at column... 63?
63 should be considered a piece of a larger column. the -a flag, aligned,
implies that all rows have the same --minimum number of spaces in the same column positions.

I'm sure this is going to play hell with streamed ssvs,
and that's a good excuse for the current mechanism.
Maybe we can add another -a -similar option
that seeks ahead through each row to find the columns that are shared in common?

--aligned-rows (-A) # reads all rows in the input to find column boundaries. Honors --minimum-spaces. Non-streaming.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions