{"id":13493806,"url":"https://github.com/thombashi/pytablewriter","last_synced_at":"2025-05-15T07:03:48.037Z","repository":{"id":37432208,"uuid":"59484958","full_name":"thombashi/pytablewriter","owner":"thombashi","description":"pytablewriter is a Python library to write a table in various formats: AsciiDoc / CSV / Elasticsearch / HTML / JavaScript / JSON / LaTeX / LDJSON / LTSV / Markdown / MediaWiki / NumPy / Excel / Pandas / Python / reStructuredText / SQLite / TOML / TSV.","archived":false,"fork":false,"pushed_at":"2025-02-23T06:17:33.000Z","size":2677,"stargazers_count":627,"open_issues_count":7,"forks_count":44,"subscribers_count":18,"default_branch":"master","last_synced_at":"2025-05-15T07:02:57.354Z","etag":null,"topics":["asciidoc","csv","elasticsearch","excel","gfm","html","javascript","json","jupyter-notebook","latex","ltsv","markdown","mediawiki","numpy","pandas","pandas-dataframe","restructuredtext","sqlite","table","toml"],"latest_commit_sha":null,"homepage":"https://pytablewriter.rtfd.io/","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/thombashi.png","metadata":{"files":{"readme":"README.rst","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":"thombashi","patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":"thombashi","issuehunt":null,"otechie":null,"custom":null}},"created_at":"2016-05-23T13:25:53.000Z","updated_at":"2025-05-13T22:32:51.000Z","dependencies_parsed_at":"2023-12-15T02:17:51.203Z","dependency_job_id":"883e2176-102a-4fb6-a743-48b35c81cc81","html_url":"https://github.com/thombashi/pytablewriter","commit_stats":{"total_commits":1989,"total_committers":9,"mean_commits":221.0,"dds":"0.30618401206636503","last_synced_commit":"0c6e6caaf1ee3814a53781f51c2bf4eb9f894ccf"},"previous_names":[],"tags_count":120,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thombashi%2Fpytablewriter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thombashi%2Fpytablewriter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thombashi%2Fpytablewriter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thombashi%2Fpytablewriter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thombashi","download_url":"https://codeload.github.com/thombashi/pytablewriter/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254291961,"owners_count":22046424,"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":["asciidoc","csv","elasticsearch","excel","gfm","html","javascript","json","jupyter-notebook","latex","ltsv","markdown","mediawiki","numpy","pandas","pandas-dataframe","restructuredtext","sqlite","table","toml"],"created_at":"2024-07-31T19:01:18.985Z","updated_at":"2025-05-15T07:03:48.016Z","avatar_url":"https://github.com/thombashi.png","language":"Python","readme":".. contents:: **pytablewriter**\n   :backlinks: top\n   :depth: 2\n\nSummary\n=========\n`pytablewriter \u003chttps://github.com/thombashi/pytablewriter\u003e`__ is a Python library to write a table in various formats: AsciiDoc / CSV / Elasticsearch / HTML / JavaScript / JSON / LaTeX / LDJSON / LTSV / Markdown / MediaWiki / NumPy / Excel / Pandas / Python / reStructuredText / SQLite / TOML / TSV / YAML.\n\n.. image:: https://badge.fury.io/py/pytablewriter.svg\n    :target: https://badge.fury.io/py/pytablewriter\n    :alt: PyPI package version\n\n.. image:: https://anaconda.org/conda-forge/pytablewriter/badges/version.svg\n    :target: https://anaconda.org/conda-forge/pytablewriter\n    :alt: conda-forge package version\n\n.. image:: https://img.shields.io/pypi/pyversions/pytablewriter.svg\n    :target: https://pypi.org/project/pytablewriter/\n    :alt: Supported Python versions\n\n.. image:: https://img.shields.io/pypi/implementation/pytablewriter.svg\n    :target: https://pypi.org/project/pytablewriter\n    :alt: Supported Python implementations\n\n.. image:: https://github.com/thombashi/pytablewriter/actions/workflows/ci.yml/badge.svg\n    :target: https://github.com/thombashi/pytablewriter/actions/workflows/ci.yml\n    :alt: CI status of Linux/macOS/Windows\n\n.. image:: https://coveralls.io/repos/github/thombashi/pytablewriter/badge.svg?branch=master\n    :target: https://coveralls.io/github/thombashi/pytablewriter?branch=master\n    :alt: Test coverage\n\n.. image:: https://github.com/thombashi/pytablewriter/actions/workflows/github-code-scanning/codeql/badge.svg\n    :target: https://github.com/thombashi/pytablewriter/actions/workflows/github-code-scanning/codeql\n    :alt: CodeQL\n\nFeatures\n--------\n- Write a table in various formats:\n    - Text formats:\n        - `AsciiDoc \u003chttps://asciidoc.org/\u003e`__\n        - CSV / Tab-separated values (TSV) / Space-separated values (SSV)\n        - HTML / CSS\n        - JSON / `Line-delimited JSON(LDJSON) \u003chttps://en.wikipedia.org/wiki/JSON_streaming#Line-delimited_JSON\u003e`__\n        - `Labeled Tab-separated Values (LTSV) \u003chttp://ltsv.org/\u003e`__\n        - LaTeX: ``tabular``/``array`` environment\n        - Markdown: CommonMark / `GitHub Flavored Markdown (GFM) \u003chttps://github.github.com/gfm/\u003e`__ / `kramdown \u003chttps://kramdown.gettalong.org/\u003e`__\n        - `MediaWiki \u003chttps://www.mediawiki.org/wiki/MediaWiki\u003e`__\n        - reStructuredText: `Grid Tables \u003chttp://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#grid-tables\u003e`__/`Simple Tables \u003chttp://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#simple-tables\u003e`__/`CSV Table \u003chttp://docutils.sourceforge.net/docs/ref/rst/directives.html#id4\u003e`__\n        - Source code (definition of a variable that represents tabular data)\n            - JavaScript / `NumPy \u003chttps://www.numpy.org/\u003e`__ (`numpy.array \u003chttps://docs.scipy.org/doc/numpy/reference/generated/numpy.array.html\u003e`__) / `Pandas \u003chttps://pandas.pydata.org/\u003e`__ (`pandas.DataFrame \u003chttps://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.html\u003e`__) / Python\n        - `TOML \u003chttps://github.com/toml-lang/toml\u003e`__\n        - `YAML \u003chttps://yaml.org/\u003e`__\n        - Unicode\n    - Binary file formats:\n        - Microsoft Excel :superscript:`TM` (``.xlsx``/``.xls`` file format)\n        - `pandas.DataFrame \u003chttps://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.html\u003e`__ pickle file\n        - `SQLite \u003chttps://www.sqlite.org/index.html\u003e`__ database\n    - Application-specific formats:\n        - `Elasticsearch \u003chttps://www.elastic.co/products/elasticsearch\u003e`__\n- Automatic table cell formatting:\n    - Alignment\n    - Padding\n    - Decimal places of numbers\n- Customize table cell styles:\n    - Text/Background color\n    - Text alignment\n    - Font size/weight\n    - Thousand separator for numbers: e.g. ``1,000``/``1 000``\n- Configure output:\n    - Write a table to a stream such as a file/standard-output/string-buffer/Jupyter-Notebook\n    - Get rendered tabular text\n- Data sources:\n    - nested list\n    - CSV\n    - `pandas.DataFrame \u003chttps://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.html\u003e`__ / `pandas.Series \u003chttps://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.Series.html\u003e`__\n    - etc.\n- Multibyte character support\n- ANSI color support\n\nInstallation\n============\n\nInstallation: pip\n------------------------------\n::\n\n    pip install pytablewriter\n\nSome of the formats require additional dependency packages, you can install these packages as follows:\n\n.. csv-table:: Installation of optional dependencies\n    :header: Installation example, Remark\n\n    ``pip install pytablewriter[es]``, Elasticsearch\n    ``pip install pytablewriter[excel]``, Excel\n    ``pip install pytablewriter[html]``, HTML\n    ``pip install pytablewriter[sqlite]``, SQLite database\n    ``pip install pytablewriter[toml]``, TOML\n    ``pip install pytablewriter[theme]``, pytablewriter theme plugins\n    ``pip install pytablewriter[all]``, Install all of the optional dependencies\n\nInstallation: conda\n------------------------------\n::\n\n    conda install -c conda-forge pytablewriter\n\nInstallation: apt\n------------------------------\n::\n\n    sudo add-apt-repository ppa:thombashi/ppa\n    sudo apt update\n    sudo apt install python3-pytablewriter\n\nExamples\n==========\nWrite tables\n--------------\nWrite a Markdown table\n~~~~~~~~~~~~~~~~~~~~~~~~\n:Sample Code:\n    .. code-block:: python\n\n        from pytablewriter import MarkdownTableWriter\n\n        def main():\n            writer = MarkdownTableWriter(\n                table_name=\"example_table\",\n                headers=[\"int\", \"float\", \"str\", \"bool\", \"mix\", \"time\"],\n                value_matrix=[\n                    [0,   0.1,      \"hoge\", True,   0,      \"2017-01-01 03:04:05+0900\"],\n                    [2,   \"-2.23\",  \"foo\",  False,  None,   \"2017-12-23 45:01:23+0900\"],\n                    [3,   0,        \"bar\",  \"true\",  \"inf\", \"2017-03-03 33:44:55+0900\"],\n                    [-10, -9.9,     \"\",     \"FALSE\", \"nan\", \"2017-01-01 00:00:00+0900\"],\n                ],\n            )\n            writer.write_table()\n\n        if __name__ == \"__main__\":\n            main()\n\n:Output:\n    .. code-block::\n\n        # example_table\n        |int|float|str |bool |  mix   |          time          |\n        |--:|----:|----|-----|-------:|------------------------|\n        |  0| 0.10|hoge|True |       0|2017-01-01 03:04:05+0900|\n        |  2|-2.23|foo |False|        |2017-12-23 12:34:51+0900|\n        |  3| 0.00|bar |True |Infinity|2017-03-03 22:44:55+0900|\n        |-10|-9.90|    |False|     NaN|2017-01-01 00:00:00+0900|\n\n:Rendering Result:\n    .. figure:: https://cdn.jsdelivr.net/gh/thombashi/pytablewriter@master/docs/pages/examples/table_format/text/ss/markdown.png\n       :scale: 80%\n       :alt: https://github.com/thombashi/pytablewriter/blob/master/docs/pages/examples/table_format/text/ss/markdown.png\n\n       Rendered markdown at GitHub\n\nWrite a Markdown table with margins\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n:Sample Code:\n    .. code-block:: python\n\n        from pytablewriter import MarkdownTableWriter\n\n        def main():\n            writer = MarkdownTableWriter(\n                table_name=\"write a table with margins\",\n                headers=[\"int\", \"float\", \"str\", \"bool\", \"mix\", \"time\"],\n                value_matrix=[\n                    [0,   0.1,      \"hoge\", True,   0,      \"2017-01-01 03:04:05+0900\"],\n                    [2,   \"-2.23\",  \"foo\",  False,  None,   \"2017-12-23 45:01:23+0900\"],\n                    [3,   0,        \"bar\",  \"true\",  \"inf\", \"2017-03-03 33:44:55+0900\"],\n                    [-10, -9.9,     \"\",     \"FALSE\", \"nan\", \"2017-01-01 00:00:00+0900\"],\n                ],\n                margin=1  # add a whitespace for both sides of each cell\n            )\n            writer.write_table()\n\n        if __name__ == \"__main__\":\n            main()\n\n:Output:\n    .. code-block::\n\n        # write a table with margins\n        | int | float | str  | bool  |   mix    |           time           |\n        | --: | ----: | ---- | ----- | -------: | ------------------------ |\n        |   0 |  0.10 | hoge | True  |        0 | 2017-01-01 03:04:05+0900 |\n        |   2 | -2.23 | foo  | False |          | 2017-12-23 12:34:51+0900 |\n        |   3 |  0.00 | bar  | True  | Infinity | 2017-03-03 22:44:55+0900 |\n        | -10 | -9.90 |      | False |      NaN | 2017-01-01 00:00:00+0900 |\n\n``margin`` attribute can be available for all of the text format writer classes.\n\nWrite a GitHub Flavored Markdown (GFM) table\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\nIf you set ``flavor`` keyword argument of ``MarkdownTableWriter`` class to ``\"github\"`` or ``\"gfm\"``, the writer will output markdown tables with GitHub flavor.\nGFM can apply some additional styles to tables such as ``fg_color`` (text color).\n\n:Sample Code:\n    .. code-block:: python\n\n            from pytablewriter import MarkdownTableWriter\n            from pytablewriter.style import Style\n\n            writer = MarkdownTableWriter(\n                column_styles=[\n                    Style(fg_color=\"red\"),\n                    Style(fg_color=\"green\", decoration_line=\"underline\"),\n                ],\n                headers=[\"A\", \"B\"],\n                value_matrix=[\n                    [\"abc\", 1],\n                    [\"efg\", 2],\n                ],\n                margin=1,\n                flavor=\"github\",\n                enable_ansi_escape=False,\n            )\n            writer.write_table()\n\nRendered results can be found at `here \u003chttps://github.com/thombashi/pytablewriter/blob/master/docs/pages/examples/output/markdown/gfm.md\u003e`__\n\nApply styles to GFM table with programmatically\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\nApplying style filters to GFM allows for more flexible style settings for cells.\nSee also the `example \u003c#style-filter\u003e`_\n\nWrite a Markdown table to a stream or a file\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n`Refer an example \u003chttps://github.com/thombashi/pytablewriter/blob/master/examples/py/stream/configure_stream.py\u003e`__\n\nWrite a table to an Excel sheet\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n:Sample Code:\n    .. code-block:: python\n\n        from pytablewriter import ExcelXlsxTableWriter\n\n        def main():\n            writer = ExcelXlsxTableWriter()\n            writer.table_name = \"example\"\n            writer.headers = [\"int\", \"float\", \"str\", \"bool\", \"mix\", \"time\"]\n            writer.value_matrix = [\n                [0,   0.1,      \"hoge\", True,   0,      \"2017-01-01 03:04:05+0900\"],\n                [2,   \"-2.23\",  \"foo\",  False,  None,   \"2017-12-23 12:34:51+0900\"],\n                [3,   0,        \"bar\",  \"true\",  \"inf\", \"2017-03-03 22:44:55+0900\"],\n                [-10, -9.9,     \"\",     \"FALSE\", \"nan\", \"2017-01-01 00:00:00+0900\"],\n            ]\n            writer.dump(\"sample.xlsx\")\n\n        if __name__ == \"__main__\":\n            main()\n\n:Output:\n    .. figure:: https://cdn.jsdelivr.net/gh/thombashi/pytablewriter@master/docs/pages/examples/table_format/binary/spreadsheet/ss/excel_single.png\n       :scale: 100%\n       :alt: https://github.com/thombashi/pytablewriter/blob/master/docs/pages/examples/table_format/binary/spreadsheet/ss/excel_single.png\n\n       Output excel file (``sample_single.xlsx``)\n\nWrite a Unicode table\n~~~~~~~~~~~~~~~~~~~~~~~\n:Sample Code:\n    .. code-block:: python\n\n        from pytablewriter import UnicodeTableWriter\n\n        def main():\n            writer = UnicodeTableWriter(\n                table_name=\"example_table\",\n                headers=[\"int\", \"float\", \"str\", \"bool\", \"mix\", \"time\"],\n                value_matrix=[\n                    [0,   0.1,      \"hoge\", True,   0,      \"2017-01-01 03:04:05+0900\"],\n                    [2,   \"-2.23\",  \"foo\",  False,  None,   \"2017-12-23 45:01:23+0900\"],\n                    [3,   0,        \"bar\",  \"true\",  \"inf\", \"2017-03-03 33:44:55+0900\"],\n                    [-10, -9.9,     \"\",     \"FALSE\", \"nan\", \"2017-01-01 00:00:00+0900\"],\n                ]\n            )\n            writer.write_table()\n\n        if __name__ == \"__main__\":\n            main()\n\n:Output:\n    .. code-block::\n\n        ┌───┬─────┬────┬─────┬────────┬────────────────────────┐\n        │int│float│str │bool │  mix   │          time          │\n        ├───┼─────┼────┼─────┼────────┼────────────────────────┤\n        │  0│ 0.10│hoge│True │       0│2017-01-01 03:04:05+0900│\n        ├───┼─────┼────┼─────┼────────┼────────────────────────┤\n        │  2│-2.23│foo │False│        │2017-12-23 12:34:51+0900│\n        ├───┼─────┼────┼─────┼────────┼────────────────────────┤\n        │  3│ 0.00│bar │True │Infinity│2017-03-03 22:44:55+0900│\n        ├───┼─────┼────┼─────┼────────┼────────────────────────┤\n        │-10│-9.90│    │False│     NaN│2017-01-01 00:00:00+0900│\n        └───┴─────┴────┴─────┴────────┴────────────────────────┘\n\nWrite a table with JavaScript format (as a nested list variable definition)\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n:Sample Code:\n    .. code-block:: python\n\n        import pytablewriter as ptw\n\n\n        def main():\n            writer = ptw.JavaScriptTableWriter(\n                table_name=\"js_variable\",\n                headers=[\"int\", \"float\", \"str\", \"bool\", \"mix\", \"time\"],\n                value_matrix=[\n                    [0, 0.1, \"hoge\", True, 0, \"2017-01-01 03:04:05+0900\"],\n                    [2, \"-2.23\", \"foo\", False, None, \"2017-12-23 45:01:23+0900\"],\n                    [3, 0, \"bar\", \"true\", \"inf\", \"2017-03-03 33:44:55+0900\"],\n                    [-10, -9.9, \"\", \"FALSE\", \"nan\", \"2017-01-01 00:00:00+0900\"],\n                ],\n            )\n\n            writer.write_table()\n\n\n        if __name__ == \"__main__\":\n            main()\n\n:Output:\n    .. code-block:: js\n\n        const js_variable = [\n            [\"int\", \"float\", \"str\", \"bool\", \"mix\", \"time\"],\n            [0, 0.1, \"hoge\", true, 0, \"2017-01-01 03:04:05+0900\"],\n            [2, -2.23, \"foo\", false, null, \"2017-12-23 45:01:23+0900\"],\n            [3, 0, \"bar\", true, Infinity, \"2017-03-03 33:44:55+0900\"],\n            [-10, -9.9, \"\", \"FALSE\", NaN, \"2017-01-01 00:00:00+0900\"]\n        ];\n\nWrite a Markdown table from ``pandas.DataFrame`` instance\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n``from_dataframe`` method of writer classes will set up tabular data from ``pandas.DataFrame``:\n\n:Sample Code:\n    .. code-block:: python\n\n        from textwrap import dedent\n        import pandas as pd\n        import io\n        from pytablewriter import MarkdownTableWriter\n\n        def main():\n            csv_data = io.StringIO(dedent(\"\"\"\\\n                \"i\",\"f\",\"c\",\"if\",\"ifc\",\"bool\",\"inf\",\"nan\",\"mix_num\",\"time\"\n                1,1.10,\"aa\",1.0,\"1\",True,Infinity,NaN,1,\"2017-01-01 00:00:00+09:00\"\n                2,2.20,\"bbb\",2.2,\"2.2\",False,Infinity,NaN,Infinity,\"2017-01-02 03:04:05+09:00\"\n                3,3.33,\"cccc\",-3.0,\"ccc\",True,Infinity,NaN,NaN,\"2017-01-01 00:00:00+09:00\"\n                \"\"\"))\n            df = pd.read_csv(csv_data, sep=',')\n\n            writer = MarkdownTableWriter(dataframe=df)\n            writer.write_table()\n\n        if __name__ == \"__main__\":\n            main()\n\n:Output:\n    .. code-block::\n\n        | i | f  | c  | if |ifc|bool |  inf   |nan|mix_num |          time           |\n        |--:|---:|----|---:|---|-----|--------|---|-------:|-------------------------|\n        |  1|1.10|aa  | 1.0|  1|True |Infinity|NaN|       1|2017-01-01 00:00:00+09:00|\n        |  2|2.20|bbb | 2.2|2.2|False|Infinity|NaN|Infinity|2017-01-02 03:04:05+09:00|\n        |  3|3.33|cccc|-3.0|ccc|True |Infinity|NaN|     NaN|2017-01-01 00:00:00+09:00|\n\n\nAdding a column of the DataFrame index if you specify ``add_index_column=True``:\n\n:Sample Code:\n    .. code-block:: python\n\n        import pandas as pd\n        import pytablewriter as ptw\n\n        def main():\n            writer = ptw.MarkdownTableWriter(table_name=\"add_index_column\")\n            writer.from_dataframe(\n                pd.DataFrame({\"A\": [1, 2], \"B\": [10, 11]}, index=[\"a\", \"b\"]),\n                add_index_column=True,\n            )\n            writer.write_table()\n\n        if __name__ == \"__main__\":\n            main()\n\n:Output:\n    .. code-block::\n\n        # add_index_column\n        |   | A | B |\n        |---|--:|--:|\n        |a  |  1| 10|\n        |b  |  2| 11|\n\nWrite a Markdown table from space-separated values\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n:Sample Code:\n    .. code-block:: python\n\n        import pytablewriter as ptw\n\n\n        def main():\n            writer = ptw.MarkdownTableWriter(table_name=\"ps\")\n            writer.from_csv(\n                \"\"\"\n                USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND\n                root         1  0.0  0.4  77664  8784 ?        Ss   May11   0:02 /sbin/init\n                root         2  0.0  0.0      0     0 ?        S    May11   0:00 [kthreadd]\n                root         4  0.0  0.0      0     0 ?        I\u003c   May11   0:00 [kworker/0:0H]\n                root         6  0.0  0.0      0     0 ?        I\u003c   May11   0:00 [mm_percpu_wq]\n                root         7  0.0  0.0      0     0 ?        S    May11   0:01 [ksoftirqd/0]\n                \"\"\",\n                delimiter=\" \",\n            )\n            writer.write_table()\n\n\n        if __name__ == \"__main__\":\n            main()\n\n:Output:\n    .. code-block::\n\n        # ps\n        |USER|PID|%CPU|%MEM| VSZ |RSS |TTY|STAT|START|TIME|   COMMAND    |\n        |----|--:|---:|---:|----:|---:|---|----|-----|----|--------------|\n        |root|  1|   0| 0.4|77664|8784|?  |Ss  |May11|0:02|/sbin/init    |\n        |root|  2|   0| 0.0|    0|   0|?  |S   |May11|0:00|[kthreadd]    |\n        |root|  4|   0| 0.0|    0|   0|?  |I\u003c  |May11|0:00|[kworker/0:0H]|\n        |root|  6|   0| 0.0|    0|   0|?  |I\u003c  |May11|0:00|[mm_percpu_wq]|\n        |root|  7|   0| 0.0|    0|   0|?  |S   |May11|0:01|[ksoftirqd/0] |\n\nGet rendered tabular text as str\n----------------------------------\n``dumps`` method returns rendered tabular text.\n``dumps`` only available for text format writers.\n\n:Sample Code:\n    .. code-block:: python\n\n        import pytablewriter as ptw\n\n\n        def main():\n            writer = ptw.MarkdownTableWriter(\n                headers=[\"int\", \"float\", \"str\", \"bool\", \"mix\", \"time\"],\n                value_matrix=[\n                    [0, 0.1, \"hoge\", True, 0, \"2017-01-01 03:04:05+0900\"],\n                    [2, \"-2.23\", \"foo\", False, None, \"2017-12-23 45:01:23+0900\"],\n                    [3, 0, \"bar\", \"true\", \"inf\", \"2017-03-03 33:44:55+0900\"],\n                    [-10, -9.9, \"\", \"FALSE\", \"nan\", \"2017-01-01 00:00:00+0900\"],\n                ],\n            )\n\n            print(writer.dumps())\n\n\n        if __name__ == \"__main__\":\n            main()\n\n:Output:\n    .. code-block::\n\n        |int|float|str |bool |  mix   |          time          |\n        |--:|----:|----|-----|-------:|------------------------|\n        |  0| 0.10|hoge|True |       0|2017-01-01 03:04:05+0900|\n        |  2|-2.23|foo |False|        |2017-12-23 45:01:23+0900|\n        |  3| 0.00|bar |True |Infinity|2017-03-03 33:44:55+0900|\n        |-10|-9.90|    |False|     NaN|2017-01-01 00:00:00+0900|\n\nConfigure table styles\n------------------------\nColumn styles\n~~~~~~~~~~~~~~~\nWriters can specify\n`Style \u003chttps://pytablewriter.rtfd.io/en/latest/pages/reference/style.html\u003e`__\nfor each column by ``column_styles`` attribute of writer classes.\n\n:Sample Code:\n    .. code-block:: python\n\n        import pytablewriter as ptw\n        from pytablewriter.style import Style\n\n\n        def main():\n            writer = ptw.MarkdownTableWriter(\n                table_name=\"set style by column_styles\",\n                headers=[\n                    \"auto align\",\n                    \"left align\",\n                    \"center align\",\n                    \"bold\",\n                    \"italic\",\n                    \"bold italic ts\",\n                ],\n                value_matrix=[\n                    [11, 11, 11, 11, 11, 11],\n                    [1234, 1234, 1234, 1234, 1234, 1234],\n                ],\n                column_styles=[\n                    Style(),\n                    Style(align=\"left\"),\n                    Style(align=\"center\"),\n                    Style(font_weight=\"bold\"),\n                    Style(font_style=\"italic\"),\n                    Style(font_weight=\"bold\", font_style=\"italic\", thousand_separator=\",\"),\n                ],  # specify styles for each column\n            )\n            writer.write_table()\n\n\n        if __name__ == \"__main__\":\n            main()\n\n:Output:\n    .. code-block::\n\n        # set style by styles\n        |auto align|left align|center align|  bold  |italic|bold italic ts|\n        |---------:|----------|:----------:|-------:|-----:|-------------:|\n        |        11|11        |     11     |  **11**|  _11_|      _**11**_|\n        |      1234|1234      |    1234    |**1234**|_1234_|   _**1,234**_|\n\n    `Rendering result \u003chttps://github.com/thombashi/pytablewriter/tree/master/docs/pages/examples/style/output.md\u003e`__\n\n\nYou can also set ``Style`` to a specific column with an index or header by using ``set_style`` method:\n\n:Sample Code:\n    .. code-block:: python\n\n        from pytablewriter import MarkdownTableWriter\n        from pytablewriter.style import Style\n\n        def main():\n            writer = MarkdownTableWriter()\n            writer.headers = [\"A\", \"B\", \"C\",]\n            writer.value_matrix = [[11, 11, 11], [1234, 1234, 1234]]\n\n            writer.table_name = \"set style by column index\"\n            writer.set_style(1, Style(align=\"center\", font_weight=\"bold\"))\n            writer.set_style(2, Style(thousand_separator=\" \"))\n            writer.write_table()\n            writer.write_null_line()\n\n            writer.table_name = \"set style by header\"\n            writer.set_style(\"B\", Style(font_style=\"italic\"))\n            writer.write_table()\n\n        if __name__ == \"__main__\":\n            main()\n\n:Output:\n    .. code-block::\n\n        # set style by column index\n        | A  |   B    |  C  |\n        |---:|:------:|----:|\n        |  11| **11** |   11|\n        |1234|**1234**|1 234|\n\n        # set style by header\n        | A  |  B   |  C  |\n        |---:|-----:|----:|\n        |  11|  _11_|   11|\n        |1234|_1234_|1 234|\n\nStyle filter\n~~~~~~~~~~~~~~\nYou can apply styles to specific cells by using style filters.\nStyle filters will be written as Python functions.\nExamples of a style filter function and how you apply it are as follows:\n\n:Sample Code:\n    .. code-block:: python\n\n            from typing import Any, Optional\n\n            from pytablewriter import MarkdownTableWriter\n            from pytablewriter.style import Cell, Style\n\n\n            def style_filter(cell: Cell, **kwargs: Any) -\u003e Optional[Style]:\n                if cell.is_header_row():\n                    return None\n\n                if cell.col == 0:\n                    return Style(font_weight=\"bold\")\n\n                value = int(cell.value)\n\n                if value \u003e 80:\n                    return Style(fg_color=\"red\", font_weight=\"bold\", decoration_line=\"underline\")\n                elif value \u003e 50:\n                    return Style(fg_color=\"yellow\", font_weight=\"bold\")\n                elif value \u003e 20:\n                    return Style(fg_color=\"green\")\n\n                return Style(fg_color=\"lightblue\")\n\n\n            writer = MarkdownTableWriter(\n                table_name=\"style filter example\",\n                headers=[\"Key\", \"Value 1\", \"Value 2\"],\n                value_matrix=[\n                    [\"A\", 95, 40],\n                    [\"B\", 55, 5],\n                    [\"C\", 30, 85],\n                    [\"D\", 0, 69],\n                ],\n                flavor=\"github\",\n                enable_ansi_escape=False,\n            )\n            writer.add_style_filter(style_filter)\n            writer.write_table()\n\nRendered results can be found at `here \u003chttps://github.com/thombashi/pytablewriter/blob/master/docs/pages/examples/output/markdown/style_filter.md\u003e`__\n\nTheme\n~~~~~~~\n`Theme \u003chttps://pytablewriter.readthedocs.io/en/latest/pages/reference/theme.html#pytablewriter.style.Theme\u003e`\nconsists of a set of style filters.\nThe following command will install external predefined themes:\n\n::\n\n    pip install pytablewriter[theme]\n\nThemes can be set via the constructor of the writer classes or the ``set_theme`` method.\nThe following is an example of setting the ``altrow`` theme via the constructor.\n``altrow`` theme will be colored rows alternatively:\n\n:Sample Code:\n    .. code-block:: python\n\n        import pytablewriter as ptw\n\n        writer = ptw.TableWriterFactory.create_from_format_name(\n            \"markdown\",\n            headers=[\"INT\", \"STR\"],\n            value_matrix=[[1, \"hoge\"], [2, \"foo\"], [3, \"bar\"]],\n            margin=1,\n            theme=\"altrow\",\n        )\n        writer.write_table()\n\n:Output:\n    .. figure:: https://cdn.jsdelivr.net/gh/thombashi/pytablewriter-altrow-theme@master/ss/ptw-altrow-theme_example_default.png\n       :scale: 100%\n       :alt: https://github.com/thombashi/pytablewriter-altrow-theme/blob/master/ss/ptw-altrow-theme_example_default.png\n\n`[theme]` extras includes the following themes:\n\n- `pytablewriter-altrow-theme \u003chttps://github.com/thombashi/pytablewriter-altrow-theme\u003e`__\n    - `Generated HTML table example \u003chttps://thombashi.github.io/pytablewriter-altrow-theme/example.html\u003e`__\n- `pytablewriter-altcol-theme \u003chttps://github.com/thombashi/pytablewriter-altcol-theme\u003e`__\n    - `Generated HTML table example \u003chttps://thombashi.github.io/pytablewriter-altcol-theme/example.html\u003e`__\n\nMake tables for specific applications\n---------------------------------------\nRender a table on Jupyter Notebook\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\nAll table writer class instances in ``pytablewriter`` can render in Jupyter Notebook.\nTo render writers at notebook cells, you will require the dependency packages to be installed either by:\n\n- ``pip install pytablewriter[html]`` or\n- ``pip install pytablewriter[all]``\n\nJupyter Notebook code examples can be found `here \u003chttps://nbviewer.jupyter.org/github/thombashi/pytablewriter/blob/master/examples/ipynb/jupyter_notebook_example.ipynb\u003e`__:\n\n.. figure:: https://cdn.jsdelivr.net/gh/thombashi/pytablewriter@master/ss/jupyter_notebook.png\n   :scale: 100%\n   :alt: https://github.com/thombashi/pytablewriter/blob/master/ss/jupyter_notebook.png\n\n   Table rendering results of Jupyter Notebook\n\nMultibyte character support\n-----------------------------\nWrite a table using multibyte character\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\nYou can use multibyte characters as table data.\nMultibyte characters are also properly padded and aligned.\n\n:Sample Code:\n    .. code-block:: python\n\n        import pytablewriter as ptw\n\n\n        def main():\n            writer = ptw.RstSimpleTableWriter(\n                table_name=\"生成に関するパターン\",\n                headers=[\"パターン名\", \"概要\", \"GoF\", \"Code Complete[1]\"],\n                value_matrix=[\n                    [\"Abstract Factory\", \"関連する一連のインスタンスを状況に応じて、適切に生成する方法を提供する。\", \"Yes\", \"Yes\"],\n                    [\"Builder\", \"複合化されたインスタンスの生成過程を隠蔽する。\", \"Yes\", \"No\"],\n                    [\"Factory Method\", \"実際に生成されるインスタンスに依存しない、インスタンスの生成方法を提供する。\", \"Yes\", \"Yes\"],\n                    [\"Prototype\", \"同様のインスタンスを生成するために、原型のインスタンスを複製する。\", \"Yes\", \"No\"],\n                    [\"Singleton\", \"あるクラスについて、インスタンスが単一であることを保証する。\", \"Yes\", \"Yes\"],\n                ],\n            )\n            writer.write_table()\n\n\n        if __name__ == \"__main__\":\n            main()\n\n:Output:\n    .. figure:: https://cdn.jsdelivr.net/gh/thombashi/pytablewriter@master/docs/pages/examples/multibyte/ss/multi_byte_char.png\n       :scale: 100%\n       :alt: https://github.com/thombashi/pytablewriter/blob/master/docs/pages/examples/multibyte/ss/multi_byte_char.png\n\n       Output of multi-byte character table\n\nMultiprocessing\n-----------------\nYou can increase the number of workers to process table data via ``max_workers`` attribute of a writer.\nThe more ``max_workers`` the less processing time when tabular data is large and the execution environment has available cores.\n\nIf you increase ``max_workers`` larger than one, recommend using main guarded as follows to avoid problems caused by multi-processing:\n\n.. code-block:: python\n\n    from multiprocessing import cpu_count\n    import pytablewriter as ptw\n\n    def main():\n        writer = ptw.MarkdownTableWriter()\n        writer.max_workers = cpu_count()\n        ...\n\n    if __name__ == \"__main__\":\n        main()\n\nFor more information\n----------------------\nMore examples are available at \nhttps://pytablewriter.rtfd.io/en/latest/pages/examples/index.html\n\nDependencies\n============\n- Python 3.9+\n- `Python package dependencies (automatically installed) \u003chttps://github.com/thombashi/pytablewriter/network/dependencies\u003e`__\n\n\nOptional dependencies\n---------------------\n- ``logging`` extras\n    - `loguru \u003chttps://github.com/Delgan/loguru\u003e`__: Used for logging if the package installed\n- ``from`` extras\n    - `pytablereader \u003chttps://github.com/thombashi/pytablereader\u003e`__\n- ``es`` extra\n    - `elasticsearch \u003chttps://github.com/elastic/elasticsearch-py\u003e`__\n- ``excel`` extras\n    - `xlwt \u003chttp://www.python-excel.org/\u003e`__\n    - `XlsxWriter \u003chttps://github.com/jmcnamara/XlsxWriter\u003e`__\n- ``html`` extras\n    - `dominate \u003chttps://github.com/Knio/dominate/\u003e`__\n- ``sqlite`` extras\n    - `SimpleSQLite \u003chttps://github.com/thombashi/SimpleSQLite\u003e`__\n- ``theme`` extras\n    - `pytablewriter-altrow-theme \u003chttps://github.com/thombashi/pytablewriter-altrow-theme\u003e`__\n    - `pytablewriter-altcol-theme \u003chttps://github.com/thombashi/pytablewriter-altcol-theme\u003e`__\n- ``toml`` extras\n    - `toml \u003chttps://github.com/uiri/toml\u003e`__\n\nDocumentation\n===============\nhttps://pytablewriter.rtfd.io/\n\nProjects using pytablewriter\n==================================\n- `pytest-md-report \u003chttps://github.com/thombashi/pytest-md-report\u003e`__\n\n\nRelated Projects\n==================================\n- `pytablereader \u003chttps://github.com/thombashi/pytablereader\u003e`__\n    - Tabular data loaded by ``pytablereader`` can be written another tabular data format with ``pytablewriter``.\n\nSponsors\n====================================\n|chasbecker| |shiguredo| |b4tman| |Arturi0| |github|\n\n.. |chasbecker| image:: https://avatars.githubusercontent.com/u/44389260?s=48\u0026u=6da7176e51ae2654bcfd22564772ef8a3bb22318\u0026v=4\n   :target: https://github.com/chasbecker\n   :alt: ex-sponsor: Charles Becker (chasbecker)\n.. |shiguredo| image:: https://avatars.githubusercontent.com/u/2549434?s=48\u0026v=4\n   :target: https://github.com/shiguredo\n   :alt: ex-sponsor: 時雨堂 (shiguredo)\n.. |b4tman| image:: https://avatars.githubusercontent.com/u/3658062?s=48\u0026v=4\n   :target: https://github.com/b4tman\n   :alt: onetime: Dmitry Belyaev (b4tman)\n.. |Arturi0| image:: https://avatars.githubusercontent.com/u/46711571?s=48\u0026u=57687c0e02d5d6e8eeaf9177f7b7af4c9f275eb5\u0026v=4\n   :target: https://github.com/Arturi0\n   :alt: onetime: Arturi0\n.. |github| image:: https://avatars.githubusercontent.com/u/9919?s=48\u0026v=4\n   :target: https://github.com/github\n   :alt: onetime: GitHub (github)\n\n`Become a sponsor \u003chttps://github.com/sponsors/thombashi\u003e`__\n\n","funding_links":["https://github.com/sponsors/thombashi","https://liberapay.com/thombashi"],"categories":["Python"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthombashi%2Fpytablewriter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthombashi%2Fpytablewriter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthombashi%2Fpytablewriter/lists"}