Open Pantsworth opened 4 years ago
The suggested change works for me when I faced this issue with this module. I have a list of dictionaries, and I want the column headers in a specific order, not the order given by .keys() on whatever happens to be the first item.
This is an awesome library!
I have a use case that's not quite covered right now. I often have a giant list of dictionaries, where each dictionary has about ~400 key:value pairs.
(Ex. I want it to ignore the data under
ignore_this_key
andand_this_one
)What I'd like to be able to do is pass a list or dictionary of headers and get an output that shows only the keys I specified in the headers (if I include all the keys as columns, it's way too beefy for my terminal)
Ex.
But right now, if I call
tabulate.tabulate(tasks, headers={'id': 'id', 'name': 'name'})
, I get:I wrote a little function that does what I want, but it would be more elegant if it was in
tabulate
itself:If this seems reasonable, I'll take a crack at a PR for it 😄. If there's already a way I can do this, apologies.