Open dvanbolt opened 3 months ago
Hello @dvanbolt , great to see your interest in this project.
great_tables
will not open a window or create a file; instead, it accumulates everything in a GT
instance. If you're running the given example with python main.py
from the command line, it will run but appear to do nothing since we're not telling Python to print anything. Like other Python programs, we need to explicitly add a print call to see the output.
However, the console might not be the best place to view our rendered table. I suggest exploring the example in jupyter-lab
. You can install Jupyter Lab with pip install jupyterlab
in your virtual environment and then type jupyter lab
to open the editor environment. If you're using VS Code, you can create a *.ipynb
file, and the editor environment will be ready for you.
Feel free to ask if you have any problems. Happy coding!
Ah...I see. Thanks so much. Got it working in Jupyter-lab. My desired pipeline is with the end table saved as a pdf and ideally without Jupyter (or just any mouse clicking i guess) as a dependency, similar to using Graphviz or the like. Once I get comfortable style library and just want to dump out files as quickly as possible, what would recommend to accomplish going from a GT() instance to an exported (html, pdf, any persistent object) with no clicking around in a browser in between?
Amazing library btw. Great work!
@dvanbolt , glad you like the project.
We have GT.as_raw_html()
to output the table as an HTML file and GT.save()
to save the table in PDF or PNG format.
Here's a small example to demonstrate how to save these formats to disk:
import polars as pl
from great_tables import GT, md, html
from great_tables.data import islands
islands_mini = (
pl.from_pandas(islands).sort("size", descending=True)
.head(10)
)
gt_tbl = GT(islands_mini)
# export HTML format
with open("gt_tbl.html", "w") as f:
f.write(gt_tbl.as_raw_html())
# export PDF format
gt_tbl.save("gt_tbl.pdf")
# export PNG format
gt_tbl.save("gt_tbl.png")
Since these functions require additional dependencies, you may need to run pip install great_tables[extra]
to get the script running.
Tremendous. Thanks so much!
I'm struggling to get gt to render/draw anything. Never once have I gotten anything to happen other than the main .py file finishing with no other windows opening/no files produced, and no output to the console. I have tried a number of example code snippets and nothing ever happens when I run them. I can print the repr of the GT() to console so the scripts are running but at no point is any .md file produced or any window opened to render anything. I assumed this was just an RFM/skill issue issue on my part but I've re-read the getting started docs and I'm at a loss. Is there any reason that python 3.11 running on Windows 10 would be an issue? I've tried multiple IDEs (and no IDE), existing project and new virtual envs and examples from this repo as well as more complex ones that use shiny to render. What am I missing here?