Skip to main content

Format a simple (i.e. not nested) list into aligned columns.

Project description

Pypi Installs Supported Python Versions

packagestatus

In showing a long lists, sometimes one would prefer to see the value arranged aligned in columns. Some examples include listing methods of an object, listing debugger commands, or showing a numeric array with data aligned.

This is a Python module to format a simple (i.e. not nested) list into aligned columns. A string with embedded newline characters is returned.

Setup

$ python >>> import columnize

With String data

Each column is only as wide as necessary. By default, columns are separated by two spaces; one was not legible enough. Set colsep to adjust the string separate columns. Set displaywidth to set the line width.

>>> g = ('bibrons', 'golden', 'madascar', 'leopard', 'mourning', 'suras', 'tokay')
>>> print(columnize.columnize(g, displaywidth=15))
bibrons   suras
golden    tokay
madascar
leopard
mourning
>>> print(columnize.columnize(g, displaywidth=19, colsep=' | '))
bibrons  | mourning
golden   | suras
madascar | tokay
leopard
>>> print(columnize.columnize(g, displaywidth=18, colsep=' | ', ljust=False))
bibrons | suras
 golden | tokay
madascar
 leopard

Normally, consecutive items go down from the top to bottom from the left-most column to the right-most. If arrange_vertical is set false, consecutive items will go across, left to right, top to bottom.

With numeric data

>>> print(columnize.columnize(['1', '2', '3', '4'], displaywidth=6)) # => '1  3\n2  4\n'
1  3
2  4
>>> print(columnize.columnize(list(range(1,6)), displaywidth=8))
1  3  5
2  4

By default entries are left justified:

>>>  print(columnize.columnize(list(range(1,16)), displaywidth=10))

1 6 11 2 7 12 3 8 13 4 9 14 5 10 15

but you can change that with ljust or if arrange_array is set to True:

>>>  print(columnize.columnize(list(range(1,16)), displaywidth=10, ljust=False))
1   6  11
2   7  12
3   8  13
4   9  14
5  10  15
>>> print(columnize.columnize(list(range(1,5)), opts={'arrange_array':True, 'displaywidth':6}))
[1, 2
 3, 4]

Credits

This module (essentially one function) was adapted from a private method of the same name from Python’s cmd module. Some adjustments and generalizations have been made.

pycolumnize for enterprise

Available as part of the Tidelift Subscription.

The maintainers of pycolumnize and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. Learn more.

Security contact information

To report a security vulnerability, please use the Tidelift security contact and Tidelift will coordinate the fix and disclosure.

Other stuff

Authors: Rocky Bernstein rb@dustyfeet.com

License: MIT

Download files

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

Source Distribution

columnize-0.3.11.tar.gz (18.8 kB view details)

Uploaded Source

Built Distributions

columnize-0.3.11-py36-none-any.whl (7.7 kB view details)

Uploaded Python 3.6

columnize-0.3.11-py3.10.egg (10.9 kB view details)

Uploaded Source

columnize-0.3.11-py3.9.egg (10.9 kB view details)

Uploaded Source

columnize-0.3.11-py3.8.egg (10.9 kB view details)

Uploaded Source

columnize-0.3.11-py3.7.egg (10.9 kB view details)

Uploaded Source

columnize-0.3.11-py3.6.egg (11.0 kB view details)

Uploaded Source

columnize-0.3.11-py3.5.egg (11.1 kB view details)

Uploaded Source

columnize-0.3.11-py3.4.egg (11.1 kB view details)

Uploaded Source

columnize-0.3.11-py3.3.egg (11.1 kB view details)

Uploaded Source

columnize-0.3.11-py3.2.egg (11.1 kB view details)

Uploaded Source

columnize-0.3.11-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

columnize-0.3.11-py2.7.egg (10.9 kB view details)

Uploaded Source

columnize-0.3.11-py2.6.egg (10.9 kB view details)

Uploaded Source

columnize-0.3.11-py2.5.egg (10.9 kB view details)

Uploaded Source

columnize-0.3.11-py2.4.egg (11.0 kB view details)

Uploaded Source

columnize-0.3.11-py2-none-any.whl (7.7 kB view details)

Uploaded Python 2

File details

Details for the file columnize-0.3.11.tar.gz.

File metadata

  • Download URL: columnize-0.3.11.tar.gz
  • Upload date:
  • Size: 18.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.6.14

File hashes

Hashes for columnize-0.3.11.tar.gz
Algorithm Hash digest
SHA256 a631b863b310a6c1457629b7bf32a3777ea5a407f8985311ce8c24c31d1d8bb2
MD5 e287d0f5ee5da9cc659ad99c4624d2b6
BLAKE2b-256 b0ab47c68ccca6052e18ccce562e6af92404b08cb2715edd9e9da31f4118cbcd

See more details on using hashes here.

Provenance

File details

Details for the file columnize-0.3.11-py36-none-any.whl.

File metadata

  • Download URL: columnize-0.3.11-py36-none-any.whl
  • Upload date:
  • Size: 7.7 kB
  • Tags: Python 3.6
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.6.14

File hashes

Hashes for columnize-0.3.11-py36-none-any.whl
Algorithm Hash digest
SHA256 10dc33cbe4ef96b777b407a96078cea2b195acfaf86592357e318180c81a83d9
MD5 65a5929812dcb44da13bf8a5e636ed79
BLAKE2b-256 ddc39902c94a4835f64d7151c6c5c40687de1438f37118d9270d15b5a2212ab1

See more details on using hashes here.

Provenance

File details

Details for the file columnize-0.3.11-py3.10.egg.

File metadata

  • Download URL: columnize-0.3.11-py3.10.egg
  • Upload date:
  • Size: 10.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.6.14

File hashes

Hashes for columnize-0.3.11-py3.10.egg
Algorithm Hash digest
SHA256 f5e68fea1f15a546dcaea846a167f48a590954788bb556571ada89f9d7b8ddcc
MD5 ef3ae2f7a7f7ef044a4619588db4e67a
BLAKE2b-256 79dfd7687e75f31cc025e0ee3e1b382461bb7fbd8e2f9472f50a35c284fa648b

See more details on using hashes here.

Provenance

File details

Details for the file columnize-0.3.11-py3.9.egg.

File metadata

  • Download URL: columnize-0.3.11-py3.9.egg
  • Upload date:
  • Size: 10.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.6.14

File hashes

Hashes for columnize-0.3.11-py3.9.egg
Algorithm Hash digest
SHA256 30f0a7d750487b4de0da1c5ca39d6aab0d9493628d24b19febee2a024a5b646f
MD5 cb62c6510035317c1b998ecf01dbe0f2
BLAKE2b-256 b0fa2ce8090659b4fa1f0b015c2ef818d77473d6e93c6539670fd6cf867781b1

See more details on using hashes here.

Provenance

File details

Details for the file columnize-0.3.11-py3.8.egg.

File metadata

  • Download URL: columnize-0.3.11-py3.8.egg
  • Upload date:
  • Size: 10.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.6.14

File hashes

Hashes for columnize-0.3.11-py3.8.egg
Algorithm Hash digest
SHA256 46a9fdb5d9625868728ecd3d075cc208732372e2f0784daf8f9bf3e3e3b7c88f
MD5 d71762220608bd805f18ff7883d76887
BLAKE2b-256 015d5b87d52b9f4daf05b3bee84c7a8eb83359221985ea18a637bb01e78d9013

See more details on using hashes here.

Provenance

File details

Details for the file columnize-0.3.11-py3.7.egg.

File metadata

  • Download URL: columnize-0.3.11-py3.7.egg
  • Upload date:
  • Size: 10.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.6.14

File hashes

Hashes for columnize-0.3.11-py3.7.egg
Algorithm Hash digest
SHA256 938d0b4f4c43ef78343906242d194ae2e7bb75952e4f976e30cf63ba2221a8f7
MD5 9e3577aad7c3c1f5a8d5688a3579ffb5
BLAKE2b-256 ec219caac93fe566e163b89493693cd7356f1a9402aca4ce384411462533d066

See more details on using hashes here.

Provenance

File details

Details for the file columnize-0.3.11-py3.6.egg.

File metadata

  • Download URL: columnize-0.3.11-py3.6.egg
  • Upload date:
  • Size: 11.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.6.14

File hashes

Hashes for columnize-0.3.11-py3.6.egg
Algorithm Hash digest
SHA256 a03e1a21c9b3b069a2243d93893640555f0f8e7d3d456af3660ab553d7adbebd
MD5 7c0351da2c2963aba22deeb352b8d68f
BLAKE2b-256 65e600e30b560cfc87a4376de4fb31336d7ab7360e4c0d644ea911a04466f544

See more details on using hashes here.

Provenance

File details

Details for the file columnize-0.3.11-py3.5.egg.

File metadata

  • Download URL: columnize-0.3.11-py3.5.egg
  • Upload date:
  • Size: 11.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.6.14

File hashes

Hashes for columnize-0.3.11-py3.5.egg
Algorithm Hash digest
SHA256 844a01077be698e7232253dc9b4c8971d93275000d7f4af17218dfaeb9bd557b
MD5 971eb26b0dea110c5129ed2fbe2edd08
BLAKE2b-256 9fcbd96afda26d147007aa1a176217205bf622d11412225a732d1592102b379a

See more details on using hashes here.

Provenance

File details

Details for the file columnize-0.3.11-py3.4.egg.

File metadata

  • Download URL: columnize-0.3.11-py3.4.egg
  • Upload date:
  • Size: 11.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.6.14

File hashes

Hashes for columnize-0.3.11-py3.4.egg
Algorithm Hash digest
SHA256 477c472c4beec17aa20a705def9b243b1846584907eb8671330c258e4a22e0e9
MD5 74e55d85b17d882ec25d3d4fb408e86a
BLAKE2b-256 7fbcd1dff951159ef3e0cc831dfff54a0e2dff36d480f081237367736f9a088c

See more details on using hashes here.

Provenance

File details

Details for the file columnize-0.3.11-py3.3.egg.

File metadata

  • Download URL: columnize-0.3.11-py3.3.egg
  • Upload date:
  • Size: 11.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.6.14

File hashes

Hashes for columnize-0.3.11-py3.3.egg
Algorithm Hash digest
SHA256 d40e31904ba0d8c024f48dc85a0aaa4f9ef19cb72238c44d93ba23873f379bd4
MD5 b39a783ad6c975d4538dd77ccbab1f90
BLAKE2b-256 211925987111865f6ffcfe200df2c26cc8bf2efa8a6ef5ac64f75c419cd02789

See more details on using hashes here.

Provenance

File details

Details for the file columnize-0.3.11-py3.2.egg.

File metadata

  • Download URL: columnize-0.3.11-py3.2.egg
  • Upload date:
  • Size: 11.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.6.14

File hashes

Hashes for columnize-0.3.11-py3.2.egg
Algorithm Hash digest
SHA256 b723c3791672b69c859e4e32a6fd2a1958a05d94874a2d2fb46c87bc8df4e817
MD5 82d972608bde267707bbb7203ac8211d
BLAKE2b-256 ed6a1ce9762634a7db08a1171ae2e2c9e63dab7ad07b997bdcdeb1723233d860

See more details on using hashes here.

Provenance

File details

Details for the file columnize-0.3.11-py3-none-any.whl.

File metadata

  • Download URL: columnize-0.3.11-py3-none-any.whl
  • Upload date:
  • Size: 7.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.6.14

File hashes

Hashes for columnize-0.3.11-py3-none-any.whl
Algorithm Hash digest
SHA256 3c474ca632e474df8f012843fb74a4c0bea4e8876d49a17f952f8e82f14cbc3d
MD5 c0b061531533a05a2b5ca83c6ff5f278
BLAKE2b-256 dedac1f84838ecb3e84c3c85c691f51f1e2dfcf7be745761d9f6462c909175ad

See more details on using hashes here.

Provenance

File details

Details for the file columnize-0.3.11-py2.7.egg.

File metadata

  • Download URL: columnize-0.3.11-py2.7.egg
  • Upload date:
  • Size: 10.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.6.14

File hashes

Hashes for columnize-0.3.11-py2.7.egg
Algorithm Hash digest
SHA256 0fe17409dbb30a3534806a69ed0540467b31276689e10383b3c989b66014666e
MD5 214b89f0138071bb8dbcc4908651a0bc
BLAKE2b-256 d66f4e875ac31ba2156466277ca44247d2295061d2b1cdc99d67892ea03f379a

See more details on using hashes here.

Provenance

File details

Details for the file columnize-0.3.11-py2.6.egg.

File metadata

  • Download URL: columnize-0.3.11-py2.6.egg
  • Upload date:
  • Size: 10.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.6.14

File hashes

Hashes for columnize-0.3.11-py2.6.egg
Algorithm Hash digest
SHA256 23db4ca4ed6a27c3a0b12407d1590729876a8983b625adcf3e1b6bf18b54e8d5
MD5 ac285d8d3c08aeaad7cf974c5bfcc901
BLAKE2b-256 01e76630dac1d79a53aa5f165e9bb2586bc2f0fbdb97480318515f94544dcf30

See more details on using hashes here.

Provenance

File details

Details for the file columnize-0.3.11-py2.5.egg.

File metadata

  • Download URL: columnize-0.3.11-py2.5.egg
  • Upload date:
  • Size: 10.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.6.14

File hashes

Hashes for columnize-0.3.11-py2.5.egg
Algorithm Hash digest
SHA256 92bbac9ec7bca0f97eb011a3b15a9703dd02a28bbcc4fda7d9d99078af68325e
MD5 b8c24ec235023e92b301339349ece72d
BLAKE2b-256 af7eb6a5ba02861ebb9cc29e3d5550ab290e0cb9ebceb5b99d83cfe158b3d184

See more details on using hashes here.

Provenance

File details

Details for the file columnize-0.3.11-py2.4.egg.

File metadata

  • Download URL: columnize-0.3.11-py2.4.egg
  • Upload date:
  • Size: 11.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.6.14

File hashes

Hashes for columnize-0.3.11-py2.4.egg
Algorithm Hash digest
SHA256 1d16a58a7fce2ec7b716e7516736cf8351bcd66583482aa542ea025244b73ae6
MD5 90dbc18af5bfe427d9849a2c1766b9ae
BLAKE2b-256 65462380ea8b3c99a61bc9d80f0e341d52a1ae32c0b7464bf152ddffc266ef40

See more details on using hashes here.

Provenance

File details

Details for the file columnize-0.3.11-py2-none-any.whl.

File metadata

  • Download URL: columnize-0.3.11-py2-none-any.whl
  • Upload date:
  • Size: 7.7 kB
  • Tags: Python 2
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.6.14

File hashes

Hashes for columnize-0.3.11-py2-none-any.whl
Algorithm Hash digest
SHA256 e4f5f53eadaddfa7bd57150d6f0ed8c7e704b82b196b17290f97fc1f5422bb54
MD5 e97b7972b01f7e05eeacaa8540077359
BLAKE2b-256 8a3fd47e953bcc8ff5b8b5f6ddcf71b2fc5d9083c54fa8ccbe76883cf8a2bf4c

See more details on using hashes here.

Provenance

Supported by

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