You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
The column command in util-linux lacks a bunch of features that PrettyTable has. It is also not too cross-platform compatible.
Maybe PrettyTable sould define a console_script/project_script entry point and implement a CLI so we can have nice tables in shell scripts.
Describe the solution
Here is a simple version of what I mean:
# t.py# Something like this but more elaborate should be part of PrettyTableimportprettytable, sysdefread_data(infile, sep=None):
with (sys.stdinifinfile=="-"elseopen(infile)) asfh:
forxinfh:
yieldx.split(sep)
defmake_table(data):
table=prettytable.PrettyTable()
table.field_names=next(data)
forrowindata:
iflen(row) !=len(table.field_names):
continuetable.add_row(row)
returntabledefmain(args=None, style=prettytable.SINGLE_BORDER):
ifargsisNone:
args=sys.argv[1:]
infile=args[0] ifargselse"-"data=read_data(infile)
table=make_table(data)
table.set_style(style)
print(table)
if__name__=="__main__":
ret=main()
raiseSystemExit(ret)
In a final implementation, the python t.py call would of course be something like pretty-table --style msword_friednly --seperator '\t' --output-format json --input-format csv or something. But for my minimal example:
$ $ echo -e "a b c d\n1 2 3 4\n5 6 7 8\n" | python t.py
┌───┬───┬───┬───┐
│ a │ b │ c │ d │
├───┼───┼───┼───┤
│ 1 │ 2 │ 3 │ 4 │
│ 5 │ 6 │ 7 │ 8 │
└───┴───┴───┴───┘
Something like it could be part of PrettyTable and of course implement more options such as --separator '\t' or --style msword_friednly. The implimentation would like be a console_script entrypoint or project.scripts entry point.
If you think something like this might get merged, I might open a PR. Beforehand, there would be some questions, like for example which argument parser to use (click, argparse) or what the command's name should be.
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem? Please describe.
The
column
command inutil-linux
lacks a bunch of features that PrettyTable has. It is also not too cross-platform compatible.Maybe PrettyTable sould define a
console_script
/project_script
entry point and implement a CLI so we can have nice tables in shell scripts.Describe the solution
Here is a simple version of what I mean:
In a final implementation, the
python t.py
call would of course be something likepretty-table --style msword_friednly --seperator '\t' --output-format json --input-format csv
or something. But for my minimal example:Something like it could be part of PrettyTable and of course implement more options such as
--separator '\t'
or--style msword_friednly
. The implimentation would like be a console_script entrypoint or project.scripts entry point.If you think something like this might get merged, I might open a PR. Beforehand, there would be some questions, like for example which argument parser to use (click, argparse) or what the command's name should be.
The text was updated successfully, but these errors were encountered: