Install & Compatibility
Where this runs
tested against v1.4.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.128s · 25.5MB
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 1.9s · import 0.120s · 26MB
21MB installed
● package 21MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
columnar
✓ from columnar import columnar
This quickstart demonstrates the basic usage of the `columnar` function to format a list of lists into a readable table. It shows how to define headers and how to apply the `no_borders` option along with custom column justification.
from columnar import columnar
data = [
['busybox', 'c3c37d5d', 'linuxnode-1', 'Test server.'],
['alpine-python', '6bb77855', 'linuxnode-2', 'The one that runs python.'],
['redis', 'afb648ba', 'linuxnode-3', 'For queues and stuff.']
]
headers = ['Name', 'ID', 'Host', 'Notes']
# Basic table
table_basic = columnar(data, headers=headers)
print('--- Basic Table ---\n')
print(table_basic)
# Table with no borders and custom justification
table_no_borders = columnar(data, headers=headers, no_borders=True, justify=['l', 'c', 'r', 'l'])
print('\n--- No Borders, Custom Justification ---\n')
print(table_no_borders)
Debug
Known issues
gotchaBe aware that this `columnar` library is for pretty-printing text tables, not for in-memory columnar data storage/processing (like Apache Arrow, Polars, or database-related columnar stores). Searching for 'columnar python' often yields results for those other, distinct, technologies.fixEnsure you are using `from columnar import columnar` for text formatting, and explore libraries like `pyarrow` or `polars` for analytical columnar data processing.
affects: All
breakingThe library explicitly states compatibility only with Python 3.6+ due to its reliance on f-strings. Usage with older Python versions will result in syntax errors.fixUpgrade your Python environment to 3.6 or newer. (e.g., `python -m pip install --upgrade python`)
affects: <3.6
gotchaWhen `no_borders=True` is passed to the `columnar` function, the table headers will be automatically converted to all uppercase characters. This is a stylistic side-effect of disabling borders.fixIf you use `no_borders=True` and need specific header casing, you must reformat the header strings *after* `columnar` has processed them, or avoid `no_borders=True`.
affects: All
gotchaPassing empty lists for data or headers might lead to unexpected output or error messages. The project history mentions fixes related to error messages for empty input lists.fixAlways provide non-empty lists for `data` and `headers` when calling `columnar`, or handle empty input gracefully in your application logic.
affects: <1.4.1 (improved error messages, but core behavior may still be unexpected)
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'columnar'
The 'columnar' library is not installed in your Python environment or the Python interpreter cannot find it in its search path.
fixInstall the library using pip: `pip install columnar`
ImportError: cannot import name 'columnar' from 'columnar' (or similar with 'Columnar')
This typically occurs if there's a typo in the import statement (e.g., incorrect casing like `Columnar` instead of `columnar`), or if a local file named `columnar.py` shadows the actual library module.
fixEnsure the import statement is `from columnar import columnar` (all lowercase for the function name). If you have a local file named `columnar.py`, rename it to avoid conflicts.
columnar.exceptions.TableOverflowError
This error is raised when the content of the columns, even after shrinking, cannot fit within the available `terminal_width` while respecting the `min_column_width` setting. This usually means there are too many columns or the data is too wide for the specified constraints.
fixReduce the number of columns, decrease `min_column_width`, or increase `terminal_width` if possible. Consider using `wrap_text=True` if column content can be wrapped.
SyntaxError: invalid syntax (related to f-strings)
The 'columnar' library (version 1.4.1) uses f-strings, which were introduced in Python 3.6. This error occurs if you are running the library with an older version of Python (e.g., Python 3.5 or earlier).
fixUpgrade your Python environment to version 3.6 or newer. For example, `python -m pip install --upgrade python` (though a full environment upgrade might be necessary).
IndexError: list index out of range (when accessing data or headers incorrectly)
This error can occur if you provide empty lists for `data` or `headers` to the `columnar` function, or if the `data` structure does not match the expected number of columns defined by `headers`.
fixAlways provide non-empty lists for `data` and `headers`, and ensure that each sub-list in `data` has the same number of elements as there are headers.
Upgrade
Version history
1.4.1latest on PyPI · released Dec 27, 2021
Audit
Dependencies
wcwidthrequiredRequired for accurate calculation of character widths in different locales, ensuring correct table rendering.