{"id":19235182,"url":"https://github.com/pyexcel-renderers/pyexcel-text","last_synced_at":"2025-04-21T05:31:51.928Z","repository":{"id":23419298,"uuid":"26781989","full_name":"pyexcel-renderers/pyexcel-text","owner":"pyexcel-renderers","description":"It is a plugin to pyexcel and provides the capability to present and write data in text formats using tabulate","archived":false,"fork":false,"pushed_at":"2017-07-30T16:48:43.000Z","size":162,"stargazers_count":11,"open_issues_count":3,"forks_count":4,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-10-07T15:38:10.977Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pyexcel-renderers.png","metadata":{"files":{"readme":"README.rst","changelog":"CHANGELOG.rst","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":"2014-11-17T23:15:32.000Z","updated_at":"2024-02-07T01:01:45.000Z","dependencies_parsed_at":"2022-07-25T10:02:03.207Z","dependency_job_id":null,"html_url":"https://github.com/pyexcel-renderers/pyexcel-text","commit_stats":null,"previous_names":["pyexcel/pyexcel-text"],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pyexcel-renderers%2Fpyexcel-text","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pyexcel-renderers%2Fpyexcel-text/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pyexcel-renderers%2Fpyexcel-text/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pyexcel-renderers%2Fpyexcel-text/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pyexcel-renderers","download_url":"https://codeload.github.com/pyexcel-renderers/pyexcel-text/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223849176,"owners_count":17213640,"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":[],"created_at":"2024-11-09T16:16:13.320Z","updated_at":"2024-11-09T16:16:13.759Z","avatar_url":"https://github.com/pyexcel-renderers.png","language":"Python","readme":"================================================================================\npyexcel-text - Let you focus on data, instead of text formats\n================================================================================\n\n\n.. image:: https://raw.githubusercontent.com/pyexcel/pyexcel.github.io/master/images/patreon.png\n   :target: https://www.patreon.com/pyexcel\n\n.. image:: https://api.travis-ci.org/pyexcel/pyexcel-text.svg?branch=master\n   :target: http://travis-ci.org/pyexcel/pyexcel-text\n\n.. image:: https://codecov.io/gh/pyexcel/pyexcel-text/branch/master/graph/badge.svg\n   :target: https://codecov.io/gh/pyexcel/pyexcel-text\n\n.. image:: https://img.shields.io/gitter/room/gitterHQ/gitter.svg\n   :target: https://gitter.im/pyexcel/Lobby\n\n\nIt is a plugin to `pyexcel \u003chttps://github.com/pyexcel/pyexcel\u003e`__ and extends\nits capbility to present and write data in text fromats mainly through `tabulate`:\n\n* \"plain\"\n* \"simple\"\n* \"grid\"\n* \"pipe\"\n* \"orgtbl\"\n* \"rst\"\n* \"mediawiki\"\n* \"latex\"\n* \"latex_booktabs\"\n* \"json\"\n* \"html\"\n\nSince v0.2.7, `json` and `ndjson` input are also supported.\n\n\nUsage\n======\n\nWhat's new?\n--------------\n\n.. code-block:: python\n\n    \u003e\u003e\u003e import pyexcel as pe\n    \u003e\u003e\u003e sheet = pe.Sheet()\n    \u003e\u003e\u003e sheet.json = '[[1,2],[2,3]]'\n    \u003e\u003e\u003e sheet\n    pyexcel sheet:\n    +---+---+\n    | 1 | 2 |\n    +---+---+\n    | 2 | 3 |\n    +---+---+\n    \u003e\u003e\u003e highspeedrail = pe.Sheet()\n    \u003e\u003e\u003e highspeedrail.json = \"\"\"\n    ... [{\"year\": 1903, \"country\": \"Germany\", \"speed\": \"206.7km/h\"},\n    ... {\"year\": 1964, \"country\": \"Japan\", \"speed\": \"210km/h\"},\n    ... {\"year\": 2008, \"country\": \"China\", \"speed\": \"350km/h\"}]\n    ... \"\"\"\n    \u003e\u003e\u003e highspeedrail.name = 'High Speed Train Speed Break Through (Source: Wikipedia)'\n    \u003e\u003e\u003e highspeedrail\n    High Speed Train Speed Break Through (Source: Wikipedia):\n    +---------+-----------+------+\n    | country | speed     | year |\n    +---------+-----------+------+\n    | Germany | 206.7km/h | 1903 |\n    +---------+-----------+------+\n    | Japan   | 210km/h   | 1964 |\n    +---------+-----------+------+\n    | China   | 350km/h   | 2008 |\n    +---------+-----------+------+\n    \u003e\u003e\u003e henley_on_thames_facts = pe.Sheet()\n    \u003e\u003e\u003e henley_on_thames_facts.json = \"\"\"\n    ... {\"area\": \"5.58 square meters\",\n    ... \"population\": \"11,619\",\n    ... \"civial parish\": \"Henley-on-Thames\",\n    ... \"latitude\": \"51.536\",\n    ... \"longitude\": \"-0.898\"\n    ... }\"\"\"\n    \u003e\u003e\u003e henley_on_thames_facts\n    pyexcel sheet:\n    +--------------------+------------------+----------+-----------+------------+\n    | area               | civial parish    | latitude | longitude | population |\n    +--------------------+------------------+----------+-----------+------------+\n    | 5.58 square meters | Henley-on-Thames | 51.536   | -0.898    | 11,619     |\n    +--------------------+------------------+----------+-----------+------------+\n    \u003e\u003e\u003e ccs_insight = pe.Sheet()\n    \u003e\u003e\u003e ccs_insight.name = \"Worldwide Mobile Phone Shipments (Billions), 2017-2021\"\n    \u003e\u003e\u003e ccs_insight.json = \"\"\"\n    ... {\"year\": [\"2017\", \"2018\", \"2019\", \"2020\", \"2021\"],\n    ... \"smart phones\": [1.53, 1.64, 1.74, 1.82, 1.90],\n    ... \"feature phones\": [0.46, 0.38, 0.30, 0.23, 0.17]}\"\"\"\n    \u003e\u003e\u003e ccs_insight\n    pyexcel sheet:\n    +----------------+--------------+------+\n    | feature phones | smart phones | year |\n    +----------------+--------------+------+\n    | 0.46           | 1.53         | 2017 |\n    +----------------+--------------+------+\n    | 0.38           | 1.64         | 2018 |\n    +----------------+--------------+------+\n    | 0.3            | 1.74         | 2019 |\n    +----------------+--------------+------+\n    | 0.23           | 1.82         | 2020 |\n    +----------------+--------------+------+\n    | 0.17           | 1.9          | 2021 |\n    +----------------+--------------+------+\n\nHere is a variant of json:\n\n    \u003e\u003e\u003e highspeedrail2 = pe.Sheet()\n    \u003e\u003e\u003e highspeedrail2.ndjson = \"\"\"\n    ... {\"year\": 1903, \"country\": \"Germany\", \"speed\": \"206.7km/h\"}\n    ... {\"year\": 1964, \"country\": \"Japan\", \"speed\": \"210km/h\"}\n    ... {\"year\": 2008, \"country\": \"China\", \"speed\": \"350km/h\"}\n    ... \"\"\".strip()\n    \u003e\u003e\u003e highspeedrail2.name = 'High Speed Train Speed Break Through (Source: Wikipedia)'\n    \u003e\u003e\u003e highspeedrail2\n    High Speed Train Speed Break Through (Source: Wikipedia):\n    +---------+-----------+------+\n    | country | speed     | year |\n    +---------+-----------+------+\n    | Germany | 206.7km/h | 1903 |\n    +---------+-----------+------+\n    | Japan   | 210km/h   | 1964 |\n    +---------+-----------+------+\n    | China   | 350km/h   | 2008 |\n    +---------+-----------+------+\n    \u003e\u003e\u003e henley_on_thames_facts2 = pe.Sheet()\n    \u003e\u003e\u003e henley_on_thames_facts2.ndjson = \"\"\"\n    ... {\"area\": \"5.58 square meters\"}\n    ... {\"population\": \"11,619\"}\n    ... {\"civial parish\": \"Henley-on-Thames\"}\n    ... {\"latitude\": \"51.536\"}\n    ... {\"longitude\": \"-0.898\"}\n    ... \"\"\".strip()\n    \u003e\u003e\u003e henley_on_thames_facts2\n    pyexcel sheet:\n    +---------------+--------------------+\n    | area          | 5.58 square meters |\n    +---------------+--------------------+\n    | population    | 11,619             |\n    +---------------+--------------------+\n    | civial parish | Henley-on-Thames   |\n    +---------------+--------------------+\n    | latitude      | 51.536             |\n    +---------------+--------------------+\n    | longitude     | -0.898             |\n    +---------------+--------------------+\n    \u003e\u003e\u003e ccs_insight2 = pe.Sheet()\n    \u003e\u003e\u003e ccs_insight2.name = \"Worldwide Mobile Phone Shipments (Billions), 2017-2021\"\n    \u003e\u003e\u003e ccs_insight2.ndjson = \"\"\"\n    ... {\"year\": [\"2017\", \"2018\", \"2019\", \"2020\", \"2021\"]}\n    ... {\"smart phones\": [1.53, 1.64, 1.74, 1.82, 1.90]}\n    ... {\"feature phones\": [0.46, 0.38, 0.30, 0.23, 0.17]}\n    ... \"\"\".strip()\n    \u003e\u003e\u003e ccs_insight2\n    pyexcel sheet:\n    +----------------+------+------+------+------+------+\n    | year           | 2017 | 2018 | 2019 | 2020 | 2021 |\n    +----------------+------+------+------+------+------+\n    | smart phones   | 1.53 | 1.64 | 1.74 | 1.82 | 1.9  |\n    +----------------+------+------+------+------+------+\n    | feature phones | 0.46 | 0.38 | 0.3  | 0.23 | 0.17 |\n    +----------------+------+------+------+------+------+\n\n\nSimple\n------------\n\n.. code-block:: python\n\n    \u003e\u003e\u003e import pyexcel as pe\n    \u003e\u003e\u003e content = [\n    ...     [\"Column 1\", \"Column 2\", \"Column 3\"],\n    ...     [1, 2, 3],\n    ...     [4, 5, 6],\n    ...     [7, 8, 9]\n    ... ]\n    \u003e\u003e\u003e sheet = pe.Sheet(content)\n    \u003e\u003e\u003e print(sheet.simple)\n    pyexcel sheet:\n    --------  --------  --------\n    Column 1  Column 2  Column 3\n    1         2         3\n    4         5         6\n    7         8         9\n    --------  --------  --------\n    \u003e\u003e\u003e sheet.name_columns_by_row(0)\n    \u003e\u003e\u003e print(sheet.simple)\n    pyexcel sheet:\n      Column 1    Column 2    Column 3\n    ----------  ----------  ----------\n             1           2           3\n             4           5           6\n             7           8           9\n\n\nGrid\n-------\n\n.. code-block:: python\n\n    \u003e\u003e\u003e print(sheet.grid)\n    pyexcel sheet:\n    +------------+------------+------------+\n    |   Column 1 |   Column 2 |   Column 3 |\n    +============+============+============+\n    |          1 |          2 |          3 |\n    +------------+------------+------------+\n    |          4 |          5 |          6 |\n    +------------+------------+------------+\n    |          7 |          8 |          9 |\n    +------------+------------+------------+\n\n\nMediawiki\n-------------\n\n.. code-block:: python\n\n    \u003e\u003e\u003e multiple_sheets = {\n    ...      'Sheet 1':\n    ...          [\n    ...              [1.0, 2.0, 3.0],\n    ...              [4.0, 5.0, 6.0],\n    ...              [7.0, 8.0, 9.0]\n    ...          ],\n    ...      'Sheet 2':\n    ...          [\n    ...              ['X', 'Y', 'Z'],\n    ...              [1.0, 2.0, 3.0],\n    ...              [4.0, 5.0, 6.0]\n    ...          ],\n    ...      'Sheet 3':\n    ...          [\n    ...              ['O', 'P', 'Q'],\n    ...              [3.0, 2.0, 1.0],\n    ...              [4.0, 3.0, 2.0]\n    ...          ]\n    ...  }\n    \u003e\u003e\u003e book = pe.Book(multiple_sheets)\n    \u003e\u003e\u003e book.save_as(\"myfile.mediawiki\")\n    \u003e\u003e\u003e myfile = open(\"myfile.mediawiki\")\n    \u003e\u003e\u003e print(myfile.read())\n    Sheet 1:\n    {| class=\"wikitable\" style=\"text-align: left;\"\n    |+ \u003c!-- caption --\u003e\n    |-\n    | align=\"right\"| 1 || align=\"right\"| 2 || align=\"right\"| 3\n    |-\n    | align=\"right\"| 4 || align=\"right\"| 5 || align=\"right\"| 6\n    |-\n    | align=\"right\"| 7 || align=\"right\"| 8 || align=\"right\"| 9\n    |}\n    Sheet 2:\n    {| class=\"wikitable\" style=\"text-align: left;\"\n    |+ \u003c!-- caption --\u003e\n    |-\n    | X   || Y   || Z\n    |-\n    | 1.0 || 2.0 || 3.0\n    |-\n    | 4.0 || 5.0 || 6.0\n    |}\n    Sheet 3:\n    {| class=\"wikitable\" style=\"text-align: left;\"\n    |+ \u003c!-- caption --\u003e\n    |-\n    | O   || P   || Q\n    |-\n    | 3.0 || 2.0 || 1.0\n    |-\n    | 4.0 || 3.0 || 2.0\n    |}\n    \u003e\u003e\u003e myfile.close()\n\nHtml\n----------\n\n.. code-block:: python\n\n    \u003e\u003e\u003e book.save_as(\"myfile.html\")\n    \u003e\u003e\u003e myfile = open(\"myfile.html\")\n    \u003e\u003e\u003e print(myfile.read()) # doctest: +SKIP\n    Sheet 1:\n    \u003ctable\u003e\n    \u003ctr\u003e\u003ctd style=\"text-align: right;\"\u003e1\u003c/td\u003e\u003ctd style=\"text-align: right;\"\u003e2\u003c/td\u003e\u003ctd style=\"text-align: right;\"\u003e3\u003c/td\u003e\u003c/tr\u003e\n    \u003ctr\u003e\u003ctd style=\"text-align: right;\"\u003e4\u003c/td\u003e\u003ctd style=\"text-align: right;\"\u003e5\u003c/td\u003e\u003ctd style=\"text-align: right;\"\u003e6\u003c/td\u003e\u003c/tr\u003e\n    \u003ctr\u003e\u003ctd style=\"text-align: right;\"\u003e7\u003c/td\u003e\u003ctd style=\"text-align: right;\"\u003e8\u003c/td\u003e\u003ctd style=\"text-align: right;\"\u003e9\u003c/td\u003e\u003c/tr\u003e\n    \u003c/table\u003e\n    Sheet 2:\n    \u003ctable\u003e\n    \u003ctr\u003e\u003ctd\u003eX  \u003c/td\u003e\u003ctd\u003eY  \u003c/td\u003e\u003ctd\u003eZ  \u003c/td\u003e\u003c/tr\u003e\n    \u003ctr\u003e\u003ctd\u003e1.0\u003c/td\u003e\u003ctd\u003e2.0\u003c/td\u003e\u003ctd\u003e3.0\u003c/td\u003e\u003c/tr\u003e\n    \u003ctr\u003e\u003ctd\u003e4.0\u003c/td\u003e\u003ctd\u003e5.0\u003c/td\u003e\u003ctd\u003e6.0\u003c/td\u003e\u003c/tr\u003e\n    \u003c/table\u003e\n    Sheet 3:\n    \u003ctable\u003e\n    \u003ctr\u003e\u003ctd\u003eO  \u003c/td\u003e\u003ctd\u003eP  \u003c/td\u003e\u003ctd\u003eQ  \u003c/td\u003e\u003c/tr\u003e\n    \u003ctr\u003e\u003ctd\u003e3.0\u003c/td\u003e\u003ctd\u003e2.0\u003c/td\u003e\u003ctd\u003e1.0\u003c/td\u003e\u003c/tr\u003e\n    \u003ctr\u003e\u003ctd\u003e4.0\u003c/td\u003e\u003ctd\u003e3.0\u003c/td\u003e\u003ctd\u003e2.0\u003c/td\u003e\u003c/tr\u003e\n    \u003c/table\u003e\n\nPlease note tabulate 0.7.7 gives an extra tbody tag around tr tag.\n\n.. testcode::\n   :hide:\n\n    \u003e\u003e\u003e myfile.close()\n    \u003e\u003e\u003e import os\n    \u003e\u003e\u003e os.unlink(\"myfile.mediawiki\")\n    \u003e\u003e\u003e os.unlink(\"myfile.html\")\n\n\nDependencies\n============\n\n* tabulate\n","funding_links":["https://www.patreon.com/pyexcel"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpyexcel-renderers%2Fpyexcel-text","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpyexcel-renderers%2Fpyexcel-text","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpyexcel-renderers%2Fpyexcel-text/lists"}