{"id":13412231,"url":"https://github.com/alttch/rapidtables","last_synced_at":"2025-04-05T23:08:03.328Z","repository":{"id":57460022,"uuid":"204223325","full_name":"alttch/rapidtables","owner":"alttch","description":"Super fast list of dicts to pre-formatted tables conversion library for Python 2/3","archived":false,"fork":false,"pushed_at":"2019-11-17T00:35:39.000Z","size":260,"stargazers_count":287,"open_issues_count":0,"forks_count":10,"subscribers_count":12,"default_branch":"master","last_synced_at":"2024-10-29T21:12:18.926Z","etag":null,"topics":["data-processing","dictionary-data","library","python","python3","text-formatting"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/alttch.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-08-24T23:23:32.000Z","updated_at":"2024-08-14T03:57:15.000Z","dependencies_parsed_at":"2022-08-28T14:01:05.308Z","dependency_job_id":null,"html_url":"https://github.com/alttch/rapidtables","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alttch%2Frapidtables","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alttch%2Frapidtables/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alttch%2Frapidtables/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alttch%2Frapidtables/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alttch","download_url":"https://codeload.github.com/alttch/rapidtables/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247411234,"owners_count":20934653,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["data-processing","dictionary-data","library","python","python3","text-formatting"],"created_at":"2024-07-30T20:01:22.398Z","updated_at":"2025-04-05T23:08:03.302Z","avatar_url":"https://github.com/alttch.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"# rapidtables\n\n**rapidtables** is a module for Python 2/3, which does only one thing: converts\nlists of dictionaries to pre-formatted tables. And it does the job as fast as\npossible.\n\n\u003cimg src=\"https://img.shields.io/pypi/v/rapidtables.svg\" /\u003e \u003cimg src=\"https://img.shields.io/badge/license-MIT-green\" /\u003e \u003cimg src=\"https://img.shields.io/badge/python-2.7%20%7C%203.5%20%7C%203.6%20%7C%203.7-blue.svg\" /\u003e\n\n**rapidtables** is focused on speed and is useful for applications which\ndynamically refresh data in console. The module code is heavily optimized and\nwritten purely in Python.\n\nAnd unlike other similar modules, **rapidtables** can output pre-formatted\ngenerators of strings or even generators of tuples of strings, which allows you\nto colorize every single column.\n\n## Install\n\n```shell\npip install rapidtables\n```\n\n## Example\n\n```python\n# if you need to keep strict column ordering, use OrderedDict for the rows\ndata = [\n    { 'name': 'John', 'salary': 2000, 'job': 'DevOps' },\n    { 'name': 'Jack', 'salary': 2500, 'job': 'Architect' },\n    { 'name': 'Diana', 'salary': None, 'job': 'Student' },\n    { 'name': 'Ken', 'salary': 1800, 'job': 'Q/A' }\n]\n\nfrom rapidtables import format_table, FORMAT_GENERATOR_COLS\nfrom termcolor import colored\n\nheader, rows = format_table(data, fmt=FORMAT_GENERATOR_COLS)\nspacer = '  '\nprint(colored(spacer.join(header), color='blue'))\nprint(colored('-' * sum([(len(x) + 2) for x in header]), color='grey'))\nfor r in rows:\n    print(colored(r[0], color='white', attrs=['bold']) + spacer, end='')\n    print(colored(r[1], color='cyan') + spacer, end='')\n    print(colored(r[2], color='yellow'))\n```\n\n![colorized cols](https://github.com/alttch/rapidtables/blob/master/examples/colored.png?raw=true)\n\nPretty cool, isn't it? Actually, it was the most complex example, you can\nwork with header + table rows already joined:\n\n```python\nfrom rapidtables import format_table, FORMAT_GENERATOR\n\nheader, rows = format_table(data, fmt=FORMAT_GENERATOR)\nprint(colored(header, color='blue'))\nprint(colored('-' * len(header), color='grey'))\nfor r in rows:\n    print(colored(r, color='yellow'))\n```\n\n![colorized rows](https://github.com/alttch/rapidtables/blob/master/examples/colored-rows.png?raw=true)\n\nOr you can use *make_table* function to return the table out-of-the-box (or\n*print_table* to instantly print it), and print it in raw:\n\n```python\nprint_table(data)\n```\n\n```\nname  salary  job\n----  ------  ---------\nJohn    2000  DevOps\nJack    2500  Architect\nKen     1800  Q/A\n```\n\n## Quick API reference\n\n### format_table\n\nFormats a table. Outputs data in raw, generator of strings (one string per row)\nor generator of tuples of strings (one tuple per row, one string per column):\n\n* **fmt=rapidtables.FORMAT_RAW** raw string\n* **fmt=rapidtables.FORMAT_GENERATOR** generator of strings\n* **fmt=rapidtables.FORMAT_GENERATOR_COLS** generator of tuples of strings\n\nAlign columns:\n\n* **align=rapidtables.ALIGN_LEFT** align all columns to left\n* **align=rapidtables.ALIGN_NUMBERS_RIGHT** align numbers to right (default)\n* **align=rapidtables.ALIGN_RIGHT** align all columns to right\n* **align=rapidtables.ALIGN_CENTER** align all columns to center\n* **align=rapidtables.ALIGN_HOMOGENEOUS_NUMBERS_RIGHT** align numbers to right\n  but consider the table is homogeneous and check col values only to first\n  number or string (works slightly faster)\n\nTo predefine aligns, set align to tuple or list:\n\n    align=(rapidtables.ALIGN_LEFT, rapidtables.ALIGN_RIGHT, ....)\n\nnumber of items in list must match number of columns in table.\n\nYou may also customize headers, separators etc. Read pydoc for more\ninfo.\n\n### make_table\n\nGenerates a ready to output table. Supports basic formats:\n\n```python\ntable = rapidtables.make_table(data, tablefmt='raw')\n```\n```\nname  salary  job\n-----------------------\nJohn     2000  DevOps\nJack     2500  Architect\nDiana          Student\nKen      1800  Q/A\n```\n\n```python\ntable = rapidtables.make_table(data, tablefmt='simple')\n```\n```\nname   salary  job\n----   ------  ---------\nJohn     2000  DevOps\nJack     2500  Architect\nDiana          Student\nKen      1800  Q/A\n``` \n\n```python\ntable = rapidtables.make_table(data, tablefmt='md') # Markdown\n```\n```\n| name  | salary | job       |\n|-------|--------|-----------|\n| John  |   2000 | DevOps    |\n| Jack  |   2500 | Architect |\n| Diana |        | Student   |\n| Ken   |   1800 | Q/A       |\n```\n\n```python\ntable = rapidtables.make_table(data, tablefmt='rst') # reStructured, simple\n```\n```\n=====  ======  =========\nname   salary  job\n=====  ======  =========\nJohn     2000  DevOps\nJack     2500  Architect\nDiana          Student\nKen      1800  Q/A\n=====  ======  =========\n```\n\n```python\ntable = rapidtables.make_table(data, tablefmt='rstgrid') # reStructured, grid\n```\n```\n+-------+--------+-----------+\n| name  | salary | job       |\n+=======+========+===========+\n| John  |   2000 | DevOps    |\n+-------+--------+-----------+\n| Jack  |   2500 | Architect |\n+-------+--------+-----------+\n| Diana |        | Student   |\n+-------+--------+-----------+\n| Ken   |   1800 | Q/A       |\n+-------+--------+-----------+\n```\n\n### print_table\n\nThe same as *make_table*, but prints table to stdout.\n\n## Benchmarks\n\n(Python 3.7)\n\n![benchmarks](https://github.com/alttch/rapidtables/blob/master/benchmarks/benchmark.png?raw=true)\n\nEnjoy!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falttch%2Frapidtables","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falttch%2Frapidtables","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falttch%2Frapidtables/lists"}