columnar
columnar copied to clipboard
Possibly to use as a generator?
I have a fairly large data set which ultimately is printed with click.echo_via_pager
. Would it be possible to supply a generator to columnar.columnar
?
Thanks
Hey @retr0h , sorry for the wait, I'm just getting back to this. I admit that I have never used click.echo_via_pager
, but taking it quick look at the docs it looks like you could write a generator that feeds chunks of text into columnar
and then yield
s the output to click
. Something like this:
import click
from columnar import columnar
def my_generator():
while True:
next_chunk = get_text_chunk_from_my_source()
if next_chunk == "":
break
next_table = columnar(next_chunk)
yield next_table
def main():
click.echo_via_pager(my_generator)
Thank you @MaxTaggart