Open zellyn opened 1 year ago
Thanks, looks like a bug.
On consulting https://pypi.org/project/tabulate/ it looks like most of those formats don't actually makes sense without headers - so the right thing here might be to raise an error if --fmt
and --no-headers
are used at the same time.
Seems to me that this is not a bug, and that @zellyn might be misunderstanding what --no-headers
is for.
The help text for --no-headers
reads: "Omit CSV headers".
(Well, it applies to TSV files, too. So the help text could be improved.)
I reckon raising an error if --no-header
is used without either --csv
or --tsv
would be good.
Furthermore, the options seem a bit messy to me. I mean, you could specify --csv
, --tsv
, and --fmt
all at once. I'd suggest at least check that none of that is happening. And make it clear in the help text that --fmt
is using the tabulate library. Don't try to hide it: that abstraction is leaking already.
My use case for using --no-headers
is almost 100% “I'm about to pass this through xargs
or some other unix utility.
But you're right that it doesn't make sense for most of the formats that are generating some kind of markup rendering.
@zellyn Which formats are you working with? I've not looked closely at the list of formats tabulate
can write, and which have headers. Are you trying to skip headers from a format that sqlite-utils
is delegating to tabulate
for? Perhaps the tabulate
library has an option for omitting a header: sqlite-utils
could pass that (or arbitrary) options to tabulate
.
Do bear in mind that if you're using a system that has the tail
command, you can use tail -n +2
as a filter to remove the first line of a text stream:
$ printf "1\n2\n3\n" | tail -n +2
2
3
Yeah, I've done the tail
thing for sure. I've mostly gotten around this now by using tsv
and only selecting one column, which basically is plain
.
Version 3.33