GT.save
GT.save(self,
file,
='table',
selector=1.0,
scale=5,
expand='chrome',
web_driver=(6000, 6000),
window_size=None,
debug_port='utf-8',
encoding=None,
_debug_dump )
Produce a high-resolution image file or PDF of the table.
The output file is created by taking a screenshot of the table using a headless browser.
Parameters
file :
Path
|str
-
The name of the file to save the image to. Accepts names ending with .png, .bmp, and other image extensions. Also accepts the extension .pdf.
selector :
str
= 'table'-
(NOT IMPLEMENTED) The HTML element name used to select table. Defaults to the whole table.
scale :
float
= 1.0-
The scaling factor that will be used when generating the image. Lower values decrease resolution. A scale of 2 is equivalent to doubling the width of the table in pixels. Note that higher resolution results in larger file sizes.
expand :
int
= 5-
(NOT IMPLEMENTED) The number of pixels to expand the screenshot by. This can be increased to capture more of the surrounding area, or decreased to capture less.
web_driver :
WebDrivers
|webdriver
.Remote
= 'chrome'-
The webdriver to use when taking the screenshot. Either a driver name, or webdriver instance. By default, uses Google Chrome. Supports
"firefox"
(Mozilla Firefox),"safari"
(Apple Safari), and"edge"
(Microsoft Edge). Specified browser must be installed. Note that if a webdriver instance is passed, options that require setting up a webdriver, like debug_port, will not be used. window_size :
tuple
[int
,int
] = (6000, 6000)-
The size of the browser window to use when laying out the table. This shouldn’t be necessary to capture a table, but may affect the tables appearance.
debug_port : None |
int
= None-
Port number to use for debugging. By default no debugging port is opened.
encoding :
str
= 'utf-8'-
The encoding used when writing temporary files.
**_debug_dump** :
DebugDumpOptions
| None = None-
Whether the saved image should be a big browser window, with key elements outlined. This is helpful for debugging this function’s resizing, cropping heuristics. This is an internal parameter and subject to change.
Returns
: None
-
This function does not return anything; it simply saves the image to the specified file path.
Details
We create the output file based on the HTML version of the table.
This process is facilitated by two libraries:
selenium
, which is used to control the Chrome browser and take a screenshot of the table.PIL
, which is used to crop the screenshot to only include the table element of the page.
Both of these packages needs to be installed before attempting to save any table as an image file. The selenium
package also requires the Chrome browser to be installed on the system.
A pip-based reinstallation of Great Tables through the following command will install these required packages:
pip install great_tables[extra]