Skip to main content

Simple, yet extendable ASCII text columnizer.

Project description

columnizer

This is a simple package for which creates columnized text tables. This is particularly useful where the text is of N length. You can use the following example, to show a good set of uses. I find this code particularly useful in command line tools.

from columnizer import *
def test_columns(columnizer):
    test_text = "the quick brown fox jumped over the lazy dogs!"
    column_count = len(columnizer.columns)
    test_rows = []
    if columnizer.first_row_headers:
        header_titles=["A","B","C","D","E","F","G","H"]
        test_rows.append(header_titles[:column_count])
    test_rows.append([test_text for _ in range(0,column_count)])
    result = columnizer.apply(test_rows)
    print (result)

c = Columnizer(
    columns=[ColumnClipped(width=25), ColumnLineWrap(width=17), ColumnWordWrap(width=17),
             ColumnWordWrap(alignment=ColumnTextAlignment.RIGHT, width=17),
             ColumnWordWrap(alignment=ColumnTextAlignment.CENTER, width=17)],
    style = ColumnTableStyleHeavy())

print ("Heavy:")
test_columns(c)

c = Columnizer(
    columns=[ColumnClipped(width=25), ColumnLineWrap(width=17), ColumnWordWrap(width=17),
             ColumnWordWrap(alignment=ColumnTextAlignment.RIGHT, width=17),
             ColumnWordWrap(alignment=ColumnTextAlignment.CENTER, width=17)])

print ("Default:")
test_columns(c)

print ("Default + Headers:")
c.first_row_headers = True
test_columns(c)

Columns are actual classes, and are used to describe the physical size and style of the columns. Rows are lists of lists, with each container list being used to store data for each column in the row.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

columnizer-0.0.1.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

columnizer-0.0.1-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

Details for the file columnizer-0.0.1.tar.gz.

File metadata

  • Download URL: columnizer-0.0.1.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.4

File hashes

Hashes for columnizer-0.0.1.tar.gz
Algorithm Hash digest
SHA256 9dd05b0d3e2d27504638e925b3b2084375b4019d4977b71fc21f169676cee9b2
MD5 9690b466cf94bf10ad5038fb161f38f2
BLAKE2b-256 79bee3c1f848014abf745262f06f00ecd271d99934402264282ca06c43977c9b

See more details on using hashes here.

File details

Details for the file columnizer-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: columnizer-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 4.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.4

File hashes

Hashes for columnizer-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d5775f6830c8d9d9bf916c8a787da0463a23a0ba1c3e411315780576a1ffcc03
MD5 0da0add0808054caffc59f1684f858bf
BLAKE2b-256 88626e041467054e2fb44cf4316f6b980b9372fe91e33c9b843a64ae86fb8635

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page