Skip to main content

It is a plugin to pyexcel and provides the capbility to present and write data in text fromats

Project description

https://travis-ci.org/chfw/pyexcel-text.svg?branch=v0.0.1-rc1 https://coveralls.io/repos/chfw/pyexcel-text/badge.png?branch=v0.0.1-rc1 https://pypip.in/d/pyexcel-text/badge.png https://pypip.in/py_versions/pyexcel-text/badge.png https://pypip.in/implementation/pyexcel-text/badge.png

It is a plugin to pyexcel and extends its capbility to present and write data in text fromats mainly through tabulate:

  • “plain”

  • “simple”

  • “grid”

  • “pipe”

  • “orgtbl”

  • “rst”

  • “mediawiki”

  • “latex”

  • “latex_booktabs”

  • “json”

Usage

>>> import pyexcel as pe
>>> import pyexcel.ext.text as text
>>> content = [
...     ["Column 1", "Column 2", "Column 3"],
...     [1, 2, 3],
...     [4, 5, 6],
...     [7, 8, 9]
... ]
>>> sheet = pe.Sheet(content)
>>> sheet
Sheet Name: pyexcel
--------  --------  --------
Column 1  Column 2  Column 3
1         2         3
4         5         6
7         8         9
--------  --------  --------
>>> sheet.name_columns_by_row(0)
>>> sheet
Sheet Name: pyexcel
  Column 1    Column 2    Column 3
----------  ----------  ----------
         1           2           3
         4           5           6
         7           8           9
>>> multiple_sheets = {
...      'Sheet 1':
...          [
...              [1.0, 2.0, 3.0],
...              [4.0, 5.0, 6.0],
...              [7.0, 8.0, 9.0]
...          ],
...      'Sheet 2':
...          [
...              ['X', 'Y', 'Z'],
...              [1.0, 2.0, 3.0],
...              [4.0, 5.0, 6.0]
...          ],
...      'Sheet 3':
...          [
...              ['O', 'P', 'Q'],
...              [3.0, 2.0, 1.0],
...              [4.0, 3.0, 2.0]
...          ]
...  }
>>> book = pe.Book(multiple_sheets)
>>> text.TABLEFMT = "rst"
>>> text.save_as(book, "myfile.rst")
>>> myfile = open("myfile.rst")
>>> print(myfile.read())
Sheet Name: Sheet 1
=  =  =
1  2  3
4  5  6
7  8  9
=  =  =
Sheet Name: Sheet 2
===  ===  ===
X    Y    Z
1.0  2.0  3.0
4.0  5.0  6.0
===  ===  ===
Sheet Name: Sheet 3
===  ===  ===
O    P    Q
3.0  2.0  1.0
4.0  3.0  2.0
===  ===  ===

Dependencies

  • tabulate

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

pyexcel-text-0.0.1.tar.gz (3.2 kB view details)

Uploaded Source

File details

Details for the file pyexcel-text-0.0.1.tar.gz.

File metadata

  • Download URL: pyexcel-text-0.0.1.tar.gz
  • Upload date:
  • Size: 3.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for pyexcel-text-0.0.1.tar.gz
Algorithm Hash digest
SHA256 6db2f00adc2f25d0c5c1099e1907603db33efea4a15fe52c5b2cadd54d210546
MD5 0832cfcb6a0af58e54f9a9615ba20ef9
BLAKE2b-256 70705317f1de88d38a8f749ad280b738a7d9fbed2b73485e0ae7d0821b0c051a

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