Skip to main content

Turn Python Dictionary into reddit table

Project description

Usage

createRedditTable(obj, headers=[], justifyString='c', outputfile='', index='index', includeIndex=False)

Basic Usage just pass in a dictionary and you get a table output to console with no ordering of headers, all columns center justified and no index included

import rtablify as rtablify

dictionary = {"apple": {'a': 1, 'b' : 2}, "banana" : {'a': 4, 'b' : 6}}
rtablify.createRedditTable(dictionary)

Output:
a|b
:-:|:-:
1|2
4|6

Include a list of headers to enforce a header order

rtablify.createRedditTable(dictionary, headers = ['b', 'a']])

Output:
b|a
:-:|:-:
2|1
6|4

Include a justify string of either 'r' for right 'c' for center and 'l' to justify columns, if you don't provide enough characters it will fill with the last in the string.

So if you had 7 columns and wanted the first left justified and all the rest centered you could pass in a string of 'lc' or 'lcccccc' both would have the same results.

Bug to fix in future relases is handle if justifyString is too long for now don't do that.

rtablify.createRedditTable(dictionary, justifyString = 'll')

Output:
a|b
--:|--:
1|2
4|6

If you include an outputfile name it will be created in the directory with a name provided and will not print to the console.

If leave on includeIndex = True (default false) The index will added into the table. If you do not specify an index name it will be called index. If you want an index it is best to include a header list to let the function know where you want the index to be.

rtablify.createRedditTable(dictionary, headers= ['index','a','b'], includeIndex = True)

Output:
index|a|b
:-:|:-:|:-:
apple|1|2
banana|4|6

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

reddit-tablify-1.0.1.tar.gz (2.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

reddit_tablify-1.0.1-py3-none-any.whl (3.0 kB view details)

Uploaded Python 3

File details

Details for the file reddit-tablify-1.0.1.tar.gz.

File metadata

  • Download URL: reddit-tablify-1.0.1.tar.gz
  • Upload date:
  • Size: 2.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.5.0.1 requests/2.20.1 setuptools/45.2.0.post20200210 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.6

File hashes

Hashes for reddit-tablify-1.0.1.tar.gz
Algorithm Hash digest
SHA256 824b26c3601e4396e4663a1a85d5a04d69b86b7ec69bbc847618781cf5335fad
MD5 40410ba763c5ee1e84a4be6ca6d45355
BLAKE2b-256 dac7e49ab6ad1ec86392ce02215962ea39519c363565c10354d72bb2138e38ae

See more details on using hashes here.

File details

Details for the file reddit_tablify-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: reddit_tablify-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 3.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.5.0.1 requests/2.20.1 setuptools/45.2.0.post20200210 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.6

File hashes

Hashes for reddit_tablify-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ebc8c9b708e3fdd1525dc6170406bc41fec5f9d721280c3fba100511a4b753d3
MD5 ffb8645dfcd1760b7176268f96a3fa29
BLAKE2b-256 11401ff07afb042054c2e9f3cf64ccbf29510b456a75f71619c216be238f1b4f

See more details on using hashes here.

Supported by

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