### Set Table Decorations Source: https://context7.com/foutaise/texttable/llms.txt Control which structural elements are drawn using bitmask constants: BORDER, HEADER, HLINES, VLINES. Combine constants with '|'. This example shows header-only and border+header styles. ```python from texttable import Texttable rows = [ ["Name", "Score", "Grade"], ["Alice", 95.5, "A"], ["Bob", 82.0, "B"], ["Charlie", 74.3, "C"], ] # Header separator only — clean minimal style table = Texttable() table.set_deco(Texttable.HEADER) table.add_rows(rows) print(table.draw()) ``` ```python # Border + header only (no inner grid lines) table2 = Texttable() table2.set_deco(Texttable.BORDER | Texttable.HEADER) table2.add_rows(rows) print(table2.draw()) ``` -------------------------------- ### Set Maximum Table Width Source: https://context7.com/foutaise/texttable/llms.txt Update the maximum rendering width after table creation. Set to 0 to disable wrapping. This example demonstrates setting a wider output and printing the table. ```python from texttable import Texttable table = Texttable() table.set_max_width(120) # allow wider output for wide terminals table.add_rows([ ["ID", "Description", "Status"], [1, "A long description that might wrap in a narrow table", "active"], [2, "Another entry with detailed info", "inactive"], ]) print(table.draw()) ``` -------------------------------- ### Set Column Horizontal Alignment Source: https://context7.com/foutaise/texttable/llms.txt Specify per-column horizontal alignment for data rows using 'l' (left), 'c' (center), or 'r' (right). This example aligns the first column left, the second right, and the third center. ```python from texttable import Texttable table = Texttable() table.set_cols_align(["l", "r", "c"]) table.add_rows([ ["Item", "Price", "Available"], ["Apple", "$1.20", "Yes"], ["Banana", "$0.50", "No"], ["Cherry", "$3.00", "Yes"], ]) print(table.draw()) ``` -------------------------------- ### Set Custom Drawing Characters Source: https://context7.com/foutaise/texttable/llms.txt Replace default line-drawing characters with custom ones. The array must contain four single-character strings: [horizontal, vertical, corner, header]. This example uses Unicode box-drawing characters. ```python from texttable import Texttable table = Texttable() table.set_chars(['─', '│', '┼', '═']) # Unicode box-drawing characters table.add_rows([ ["Product", "Price", "Stock"], ["Widget", 9.99, 150], ["Gadget", 24.50, 42], ]) print(table.draw()) ``` -------------------------------- ### Create and Draw a Basic Text Table Source: https://github.com/foutaise/texttable/blob/master/README.md Demonstrates creating a Texttable instance, setting column alignments and vertical alignments, adding rows with multi-line text, and drawing the table. Use for standard table generation with complex cell content. ```python table = Texttable() table.set_cols_align(["l", "r", "c"]) table.set_cols_valign(["t", "m", "b"]) table.add_rows([["Name", "Age", "Nickname"], ["Mr\nXavier\nHuon", 32, "Xav'"], ["Mr\n Baptiste\nClement", 1, "Baby"], ["Mme\n Louise\nBourgeau", 28, "Lou\n\nLoue"]]) print(table.draw()) print() ``` -------------------------------- ### Create a Text Table with Header and Data Types Source: https://github.com/foutaise/texttable/blob/master/README.md Shows how to create a Texttable with specific column data types (text, float, exponent, integer, automatic) and alignment, using the HEADER decoration. Useful for tables with mixed data types and a distinct header row. ```python table = Texttable() table.set_deco(Texttable.HEADER) table.set_cols_dtype(['t', # text 'f', # float (decimal) 'e', # float (exponent) 'i', # integer 'a']) # automatic table.set_cols_align(["l", "r", "r", "r", "l"]) table.add_rows([["text", "float", "exp", "int", "auto"], ["abcd", "67", 654, 89, 128.001], ["efghijk", "67.5434", .654, 89.6, 12800000000000000000000.00023], ["lmn", 5e-78, 5e-78, 89.4, .000000000000128], ["opqrstu", .023, 5e+78, 92., 12800000000000000000000]]) print(table.draw()) ``` -------------------------------- ### Texttable Constructor Source: https://context7.com/foutaise/texttable/llms.txt Initializes a new Texttable instance. Supports setting the maximum table width and enables all decorations by default. ```APIDOC ## Texttable(max_width=80) - Constructor Creates a new table instance with all decorations enabled by default. `max_width` controls the total table width in characters; cells are wrapped to fit. Set `max_width=0` for unlimited width with no wrapping. ### Usage ```python from texttable import Texttable # Default: max width 80 characters, all decorations on table = Texttable() # Unlimited width — no cell wrapping table_wide = Texttable(max_width=0) # Narrow table — cells will wrap to fit 40 chars total table_narrow = Texttable(max_width=40) ``` ``` -------------------------------- ### Initialize Texttable with Max Width Source: https://context7.com/foutaise/texttable/llms.txt Instantiate Texttable with default max width (80 chars), unlimited width (0), or a specific narrow width. Cells wrap to fit the specified max_width. ```python from texttable import Texttable # Default: max width 80 characters, all decorations on table = Texttable() # Unlimited width — no cell wrapping table_wide = Texttable(max_width=0) # Narrow table — cells will wrap to fit 40 chars total table_narrow = Texttable(max_width=40) ``` -------------------------------- ### Texttable Constructor Source: https://github.com/foutaise/texttable/blob/master/README.md Initializes a new Texttable object. The max_width parameter controls the maximum width of the table, with 0 disabling wrapping. ```APIDOC ## __init__ Texttable ### Description Constructor for the Texttable class. ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Method __init__ ### Parameters * **max_width** (integer) - Optional - Specifies the maximum width of the table. If set to 0, the size is unlimited and cells won't be wrapped. ``` -------------------------------- ### Render Table with Decorations and Data Types - Texttable Source: https://context7.com/foutaise/texttable/llms.txt Configures a Texttable with specific decorations, column alignments, and data types before drawing the table. The `draw()` method returns the formatted table as a string. ```python from texttable import Texttable table = Texttable(max_width=60) table.set_deco(Texttable.BORDER | Texttable.HEADER | Texttable.VLINES) table.set_cols_dtype(["t", "i", "f", "b"]) table.set_cols_align(["l", "r", "r", "c"]) table.add_rows([ ["Name", "Qty", "Price", "In Stock"], ["Pen", 500, 0.99, True], ["Notebook", 120, 4.49, True], ["Eraser", 300, 0.49, False], ]) output = table.draw() if output: print(output) ``` -------------------------------- ### Draw Table Source: https://github.com/foutaise/texttable/blob/master/README.md Renders the table as a formatted string. ```APIDOC ## draw Texttable ### Description Draws the table and returns it as a whole string. ### Method draw ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Response #### Success Response (200) * **table_string** (string) - The formatted ASCII table. ``` -------------------------------- ### Set Table Header Separately with header() Source: https://context7.com/foutaise/texttable/llms.txt Allows setting the header row independently, which is useful when rows are added incrementally. Column alignment and width can also be configured. ```python from texttable import Texttable table = Texttable() table.header(["Timestamp", "Level", "Message"]) table.set_cols_align(["l", "c", "l"]) table.set_cols_width([19, 8, 40]) # Add rows one by one (e.g., streaming log lines) log_entries = [ ("2024-06-01 10:00:01", "INFO", "Server started on port 8080"), ("2024-06-01 10:00:45", "WARNING", "Memory usage above 80%"), ("2024-06-01 10:01:02", "ERROR", "Database connection timeout"), ] for ts, level, msg in log_entries: table.add_row([ts, level, msg]) print(table.draw()) ``` -------------------------------- ### add_rows(rows, header=True) Source: https://context7.com/foutaise/texttable/llms.txt Adds multiple rows to the table at once using a 2D array or an iterator. If `header=True` (the default), the first row in the input is treated as the table header. Set `header=False` to include all rows as data. ```APIDOC ## `add_rows(rows, header=True)` — Add Multiple Rows at Once Adds a 2D array or iterator of rows in one call. When `header=True` (default), the first row is treated as the table header; set `header=False` to treat all rows as data rows. ```python from texttable import Texttable # header=True (default): first row becomes the header table = Texttable() table.add_rows([ ["City", "Country", "Population"], ["Tokyo", "Japan", 13_960_000], ["Delhi", "India", 32_940_000], ["Shanghai", "China", 28_516_000], ["São Paulo", "Brazil", 22_430_000], ]) print(table.draw()) ``` ``` -------------------------------- ### Add Rows Without Header - Texttable Source: https://context7.com/foutaise/texttable/llms.txt Demonstrates adding rows to a Texttable instance where the header is not explicitly set, and the first row is treated as data. Ensure header is set separately if needed. ```python from texttable import Texttable table2 = Texttable() table2.header(["X", "Y", "Z"]) table2.add_rows([[1, 2, 3], [4, 5, 6]], header=False) print(table2.draw()) ``` -------------------------------- ### Set Column Widths Source: https://context7.com/foutaise/texttable/llms.txt Explicitly sets the width of each column in characters, overriding auto-computed widths. All values must be positive integers. ```python from texttable import Texttable table = Texttable(max_width=0) # disable auto max_width so manual widths apply cleanly table.set_cols_width([15, 40, 10]) table.add_rows([ ["Field", "Value", "Type"], ["username", "john_doe", "string"], ["email", "john.doe@example.com", "string"], ["signup_date", "2024-03-15", "date"], ["score", "9823746523", "integer"], ]) print(table.draw()) ``` -------------------------------- ### Reset Table Data While Preserving Formatting - Texttable Source: https://context7.com/foutaise/texttable/llms.txt Shows how to reuse a Texttable instance with new data by calling `reset()`. This clears existing rows and headers but keeps all formatting settings like alignment, data types, and precision. ```python from texttable import Texttable table = Texttable() table.set_cols_align(["l", "r"]) table.set_cols_dtype(["t", "f"]) table.set_precision(2) # First dataset table.add_rows([["Item", "Cost"], ["Coffee", 3.5], ["Tea", 2.0]]) print("=== Drinks ===") print(table.draw()) # Reuse same formatting for second dataset table.reset() table.add_rows([["Item", "Cost"], ["Sandwich", 6.75], ["Salad", 8.50]]) print("\n=== Food ===") print(table.draw()) ``` -------------------------------- ### Set Header Source: https://github.com/foutaise/texttable/blob/master/README.md Explicitly sets the header row for the table. ```APIDOC ## header Texttable ### Description Specifies the header of the table. ### Method header ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters * **array** (list) - Required - A list representing the cells of the header row. ``` -------------------------------- ### set_chars Source: https://context7.com/foutaise/texttable/llms.txt Allows customization of the characters used for drawing table borders and lines. You can replace the default characters with custom ones, including Unicode box-drawing characters. ```APIDOC ## set_chars(array) Replaces the four default line-drawing characters `['-', '|', '+', '=']` with custom ones. The array must contain exactly four single-character strings: `[horizontal, vertical, corner, header]`. ### Parameters - **array** (list of str) - A list containing four single characters for horizontal, vertical, corner, and header lines. ### Usage ```python from texttable import Texttable table = Texttable() table.set_chars(['─', '│', '┼', '═']) # Unicode box-drawing characters table.add_rows([ ["Product", "Price", "Stock"], ["Widget", 9.99, 150], ["Gadget", 24.50, 42], ]) print(table.draw()) ``` ``` -------------------------------- ### set_cols_width Source: https://github.com/foutaise/texttable/blob/master/README.md Sets the desired width for each column in the table. The input should be a list of integers, where each integer represents the width of a corresponding column. ```APIDOC ## set_cols_width(self, array) ### Description Set the desired columns width. ### Parameters #### Path Parameters - **array** (list of int) - Required - A list of integers specifying the width of each column. Example: `[10, 20, 5]` ``` -------------------------------- ### Handle Mismatched Row Sizes with ArraySizeError - Texttable Source: https://context7.com/foutaise/texttable/llms.txt Demonstrates catching `ArraySizeError` when adding rows or setting column configurations with an incorrect number of elements. This exception is raised when array sizes do not match the established column count. ```python from texttable import Texttable, ArraySizeError table = Texttable() table.header(["Col A", "Col B", "Col C"]) try: table.add_row(["value1", "value2"]) except ArraySizeError as e: print(f"Error: {e}") try: table.set_cols_align(["l", "r"]) except ArraySizeError as e: print(f"Error: {e}") ``` -------------------------------- ### Add Rows Source: https://github.com/foutaise/texttable/blob/master/README.md Adds multiple rows to the table. The 'header' argument determines if the first row is treated as a header. ```APIDOC ## add_rows Texttable ### Description Adds multiple rows to the table. ### Method add_rows ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters * **rows** (iterator or list of lists) - Required - An iterator returning arrays or a 2D array representing the rows to add. * **header** (boolean) - Optional - Specifies if the first row should be used as the header of the table. Defaults to True. ``` -------------------------------- ### Set Characters Source: https://github.com/foutaise/texttable/blob/master/README.md Defines the characters used for drawing table borders and lines. ```APIDOC ## set_chars Texttable ### Description Sets the characters used to draw lines between rows and columns. ### Method set_chars ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters * **array** (list) - Required - A list containing four fields: [horizontal, vertical, corner, header]. Default is ['-', '|', '+', '='] ``` -------------------------------- ### Reset Table Source: https://github.com/foutaise/texttable/blob/master/README.md Resets the table instance, clearing all rows and header information. ```APIDOC ## reset Texttable ### Description Resets the instance, clearing rows and header. ### Method reset ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ``` -------------------------------- ### set_max_width Source: https://github.com/foutaise/texttable/blob/master/README.md Sets the maximum width of the table. If set to 0, the table width is unlimited and cells will not wrap. ```APIDOC ## set_max_width(self, max_width) ### Description Set the maximum width of the table. ### Parameters #### Path Parameters - **max_width** (int) - Required - The maximum width of the table. Set to 0 for unlimited width. ``` -------------------------------- ### Set Float Precision with set_precision() Source: https://context7.com/foutaise/texttable/llms.txt Controls the number of decimal places for float and exponential columns. The default is 3. Must be a non-negative integer. ```python from texttable import Texttable table = Texttable() table.set_deco(Texttable.HEADER | Texttable.BORDER) table.set_precision(5) table.set_cols_dtype(["t", "f", "e"]) table.set_cols_align(["l", "r", "r"]) table.add_rows([ ["Measurement", "Decimal", "Scientific"], ["Pi", 3.14159265, 3.14159265], ["Planck", 6.62607e-34, 6.62607e-34], ["Avogadro", 6.02214e+23, 6.02214e+23], ]) print(table.draw()) ``` -------------------------------- ### set_precision(width) Source: https://context7.com/foutaise/texttable/llms.txt Sets the number of decimal places used when formatting 'f' (float) and 'e' (exponential) columns. The default is 3. This value must be a non-negative integer. ```APIDOC ## `set_precision(width)` — Set Float Precision Sets the number of decimal places used when formatting `"f"` (float) and `"e"` (exponential) columns. Default is `3`. Must be a non-negative integer. ```python from texttable import Texttable table = Texttable() table.set_deco(Texttable.HEADER | Texttable.BORDER) table.set_precision(5) table.set_cols_dtype(["t", "f", "e"]) table.set_cols_align(["l", "r", "r"]) table.add_rows([ ["Measurement", "Decimal", "Scientific"], ["Pi", 3.14159265, 3.14159265], ["Planck", 6.62607e-34, 6.62607e-34], ["Avogadro", 6.02214e+23, 6.02214e+23], ]) print(table.draw()) ``` ``` -------------------------------- ### Add Multiple Rows with add_rows() Source: https://context7.com/foutaise/texttable/llms.txt Adds a 2D array or iterator of rows efficiently. By default, the first row is treated as the header; set `header=False` to include all rows as data. ```python from texttable import Texttable # header=True (default): first row becomes the header table = Texttable() table.add_rows([ ["City", "Country", "Population"], ["Tokyo", "Japan", 13_960_000], ["Delhi", "India", 32_940_000], ["Shanghai", "China", 28_516_000], ["São Paulo", "Brazil", 22_430_000], ]) print(table.draw()) ``` -------------------------------- ### Set Column Data Type Source: https://github.com/foutaise/texttable/blob/master/README.md Specifies the data type for each column, influencing formatting and alignment. ```APIDOC ## set_cols_dtype Texttable ### Description Sets the desired data type for each column. ### Method set_cols_dtype ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters * **array** (list) - Required - A list where each element specifies the data type for the corresponding column. Accepted values are 'a' (automatic), 't' (text), 'f' (float decimal), 'e' (float exponential), 'i' (integer), 'b' (boolean), or a callable function for custom formatting. ``` -------------------------------- ### set_deco Source: https://github.com/foutaise/texttable/blob/master/README.md Sets the table decoration. 'deco' can be a combination of predefined constants like BORDER, HEADER, HLINES, and VLINES. ```APIDOC ## set_deco(self, deco) ### Description Set the table decoration. ### Parameters #### Path Parameters - **deco** (int) - Required - A combination of Texttable constants (BORDER, HEADER, HLINES, VLINES) to define table borders and lines. Example: `Texttable.BORDER | Texttable.HEADER` ``` -------------------------------- ### set_precision Source: https://github.com/foutaise/texttable/blob/master/README.md Sets the precision for floating-point and exponential number formats. The default precision is 3. ```APIDOC ## set_precision(self, width) ### Description Set the desired precision for float/exponential formats. ### Parameters #### Path Parameters - **width** (int) - Required - The desired precision for float/exponential formats. Must be an integer greater than or equal to 0. Default is 3. ``` -------------------------------- ### header(array) Source: https://context7.com/foutaise/texttable/llms.txt Sets the table header row independently. This method is useful when rows are added incrementally using `add_row`, allowing the header to be defined separately from the data rows. ```APIDOC ## `header(array)` — Set Table Header Separately Sets the header row independently, without using `add_rows`. Useful when rows are added incrementally via `add_row`. ```python from texttable import Texttable table = Texttable() table.header(["Timestamp", "Level", "Message"]) table.set_cols_align(["l", "c", "l"]) table.set_cols_width([19, 8, 40]) # Add rows one by one (e.g., streaming log lines) log_entries = [ ("2024-06-01 10:00:01", "INFO", "Server started on port 8080"), ("2024-06-01 10:00:45", "WARNING", "Memory usage above 80%"), ("2024-06-01 10:01:02", "ERROR", "Database connection timeout"), ] for ts, level, msg in log_entries: table.add_row([ts, level, msg]) print(table.draw()) ``` ``` -------------------------------- ### Set Column Alignment Source: https://github.com/foutaise/texttable/blob/master/README.md Configures the horizontal alignment for each column. ```APIDOC ## set_cols_align Texttable ### Description Sets the desired horizontal alignment for each column. ### Method set_cols_align ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters * **array** (list) - Required - A list of strings, where each element is 'l' (left), 'c' (center), or 'r' (right) for the corresponding column. ``` -------------------------------- ### set_cols_width Source: https://context7.com/foutaise/texttable/llms.txt Explicitly sets the width (in characters) of each column, overriding auto-computed widths. All values must be positive integers. ```APIDOC ## `set_cols_width(array)` — Set Column Widths Explicitly sets the width (in characters) of each column, overriding auto-computed widths. All values must be positive integers. ### Method ```python table.set_cols_width([15, 40, 10]) ``` ### Parameters * **array** (list of integers) - A list of positive integers specifying the width for each column. ``` -------------------------------- ### Set Column Data Types Source: https://context7.com/foutaise/texttable/llms.txt Controls how cell values are formatted. Supports automatic, text, float, exponential, integer, boolean, or custom callables. ```python from texttable import Texttable table = Texttable() table.set_deco(Texttable.HEADER) table.set_cols_dtype([ 't', # text — no conversion 'f', # float decimal 'e', # float exponential 'i', # integer (rounds floats) 'b', # boolean lambda x: f"${x:,.2f}", # custom callable ]) table.set_cols_align(["l", "r", "r", "r", "c", "r"]) table.add_rows([ ["Label", "Float", "Exp", "Int", "Bool", "Custom"], ["row-1", 67.5, 654.0, 89.6, 1, 1999.5], ["row-2", 5e-10, 5e-10, 0.7, 0, 42000.0], ["row-3", 0.023, 5e+12, 92.4, True, 500.0], ]) print(table.draw()) ``` -------------------------------- ### set_header_align Source: https://github.com/foutaise/texttable/blob/master/README.md Sets the alignment for the table headers. The input should be a list of characters, where each character specifies the alignment ('l', 'c', or 'r') for a corresponding header. ```APIDOC ## set_header_align(self, array) ### Description Set the desired header alignment. ### Parameters #### Path Parameters - **array** (list of str) - Required - A list of characters ('l', 'c', or 'r') specifying the alignment for each header. 'l' for left, 'c' for center, 'r' for right. ``` -------------------------------- ### Add a Single Row with add_row() Source: https://context7.com/foutaise/texttable/llms.txt Appends a single data row to the table. Cells can contain newlines (\n) and tabs (\t) for multi-line or tabulated content within a cell. ```python from texttable import Texttable table = Texttable() table.header(["Package", "Version", "License"]) table.set_cols_align(["l", "c", "c"]) packages = [ ("requests", "2.31.0", "Apache 2.0"), ("numpy", "1.26.4", "BSD"), ("flask", "3.0.2", "BSD"), ("sqlalchemy", "2.0.29", "MIT"), ] for name, ver, lic in packages: table.add_row([name, ver, lic]) print(table.draw()) ``` -------------------------------- ### add_row(array) Source: https://context7.com/foutaise/texttable/llms.txt Appends a single data row to the table. Each cell within the row can contain newline characters (`\n`) and tab characters (`\t`) to format multi-line or tabulated content within a cell. ```APIDOC ## `add_row(array)` — Add a Single Row Appends a single data row to the table. Cells may contain newlines (`\n`) and tabs (`\t`) for multi-line or tabulated content. ```python from texttable import Texttable table = Texttable() table.header(["Package", "Version", "License"]) table.set_cols_align(["l", "c", "c"]) packages = [ ("requests", "2.31.0", "Apache 2.0"), ("numpy", "1.26.4", "BSD"), ("flask", "3.0.2", "BSD"), ("sqlalchemy", "2.0.29", "MIT"), ] for name, ver, lic in packages: table.add_row([name, ver, lic]) print(table.draw()) ``` ``` -------------------------------- ### Add Row Source: https://github.com/foutaise/texttable/blob/master/README.md Adds a single row to the table. Cells in the row can contain newline characters and tabs. ```APIDOC ## add_row Texttable ### Description Adds a single row to the table. ### Method add_row ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters * **array** (list) - Required - A list representing the cells of the row. Cells can contain newlines and tabs. ``` -------------------------------- ### Set Column Vertical Alignment Source: https://github.com/foutaise/texttable/blob/master/README.md Configures the vertical alignment for content within each column's cells. ```APIDOC ## set_cols_valign Texttable ### Description Sets the desired vertical alignment for each column. ### Method set_cols_valign ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters * **array** (list) - Required - A list of strings, where each element is 't' (top), 'm' (middle), or 'b' (bottom) for the corresponding column. ``` -------------------------------- ### Set Column Vertical Alignment Source: https://context7.com/foutaise/texttable/llms.txt Sets per-column vertical alignment for multi-line cells. Values: 't' (top), 'm' (middle), 'b' (bottom). ```python from texttable import Texttable table = Texttable() table.set_cols_align(["l", "r", "c"]) table.set_cols_valign(["t", "m", "b"]) table.add_rows([ ["Name", "Age", "Nickname"], ["Mr\nXavier\nHuon", 32, "Xav'"], ["Mr\n Baptiste\nClement", 1, "Baby"], ["Mme\nLouise\nBourgeau", 28, "Lou\n\nLoue"], ]) print(table.draw()) ``` -------------------------------- ### set_deco Source: https://context7.com/foutaise/texttable/llms.txt Controls which structural elements of the table are drawn. This method uses bitmask constants to enable or disable borders, header separators, and inner lines. ```APIDOC ## set_deco(deco) Controls which structural elements are drawn using bitmask constants: `Texttable.BORDER` (outer border), `Texttable.HEADER` (line below header), `Texttable.HLINES` (lines between rows), `Texttable.VLINES` (lines between columns). Combine with `|`; all four are enabled by default. ### Parameters - **deco** (int) - A bitmask combining `Texttable.BORDER`, `Texttable.HEADER`, `Texttable.HLINES`, and `Texttable.VLINES`. ### Usage ```python from texttable import Texttable rows = [ ["Name", "Score", "Grade"], ["Alice", 95.5, "A"], ["Bob", 82.0, "B"], ["Charlie", 74.3, "C"], ] # Header separator only — clean minimal style table = Texttable() table.set_deco(Texttable.HEADER) table.add_rows(rows) print(table.draw()) # Border + header only (no inner grid lines) table2 = Texttable() table2.set_deco(Texttable.BORDER | Texttable.HEADER) table2.add_rows(rows) print(table2.draw()) ``` ``` -------------------------------- ### set_cols_align Source: https://context7.com/foutaise/texttable/llms.txt Specifies the horizontal alignment for text within each column. You can set alignment to left ('l'), center ('c'), or right ('r') for each column individually. ```APIDOC ## set_cols_align(array) Specifies per-column horizontal alignment for data rows. Each element must be `"l"` (left), `"c"` (center), or `"r"` (right). ### Parameters - **array** (list of str) - A list of alignment characters ('l', 'c', 'r') for each column. ### Usage ```python from texttable import Texttable table = Texttable() table.set_cols_align(["l", "r", "c"]) table.add_rows([ ["Item", "Price", "Available"], ["Apple", "$1.20", "Yes"], ["Banana", "$0.50", "No"], ["Cherry", "$3.00", "Yes"], ]) print(table.draw()) ``` ``` -------------------------------- ### Set Header Horizontal Alignment Source: https://context7.com/foutaise/texttable/llms.txt Controls horizontal alignment of the header row independently from data rows. Accepts 'l', 'c', 'r' values. ```python from texttable import Texttable table = Texttable() table.set_header_align(["c", "c", "r"]) # headers all centered or right table.set_cols_align(["l", "l", "r"]) # data: left, left, right-aligned table.add_rows([ ["Server", "Region", "Uptime %"], ["web-01", "us-east-1", 99.95], ["db-01", "eu-west-2", 99.80], ["cache-1", "ap-south", 100.00], ]) print(table.draw()) ``` -------------------------------- ### set_cols_valign Source: https://context7.com/foutaise/texttable/llms.txt Sets per-column vertical alignment for multi-line cells. Values can be 't' (top), 'm' (middle), or 'b' (bottom). ```APIDOC ## `set_cols_valign(array)` — Set Column Vertical Alignment Sets per-column vertical alignment for multi-line cells. Values: `"t"` (top), `"m"` (middle), `"b"` (bottom). ### Method ```python table.set_cols_valign(["t", "m", "b"]) ``` ### Parameters * **array** (list of strings) - A list containing vertical alignment characters ('t', 'm', 'b') for each column. ``` -------------------------------- ### set_cols_dtype Source: https://context7.com/foutaise/texttable/llms.txt Controls how cell values are formatted. Supports automatic, text, float, exponential, integer, boolean, or custom callable formatting. ```APIDOC ## `set_cols_dtype(array)` — Set Column Data Types Controls how cell values are formatted. Each element can be: `"a"` (automatic), `"t"` (text), `"f"` (float/decimal), `"e"` (float/exponential), `"i"` (integer), `"b"` (boolean), or any callable that returns a formatted string. ### Method ```python table.set_cols_dtype([ 't', 'f', 'e', 'i', 'b', lambda x: f"${x:,.2f}" ]) ``` ### Parameters * **array** (list) - A list where each element specifies the data type or a formatting function for the corresponding column. ``` -------------------------------- ### set_header_align Source: https://context7.com/foutaise/texttable/llms.txt Controls horizontal alignment of the header row independently from data rows. Accepts 'l', 'c', or 'r' values. ```APIDOC ## `set_header_align(array)` — Set Header Horizontal Alignment Controls horizontal alignment of the header row independently from data rows. Accepts the same `"l"`, `"c"`, `"r"` values as `set_cols_align`. ### Method ```python table.set_header_align(["c", "c", "r"]) ``` ### Parameters * **array** (list of strings) - A list containing alignment characters ('l', 'c', 'r') for each column. ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.