pyexcel-text - Let you focus on data, instead of text formats
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”
“html”
Usage
Simple
>>> import pyexcel as pe
>>> content = [
... ["Column 1", "Column 2", "Column 3"],
... [1, 2, 3],
... [4, 5, 6],
... [7, 8, 9]
... ]
>>> sheet = pe.Sheet(content)
>>> print(sheet.simple)
Sheet Name: pyexcel
-------- -------- --------
Column 1 Column 2 Column 3
1 2 3
4 5 6
7 8 9
-------- -------- --------
<BLANKLINE>
>>> sheet.name_columns_by_row(0)
>>> print(sheet.simple)
Sheet Name: pyexcel
Column 1 Column 2 Column 3
---------- ---------- ----------
1 2 3
4 5 6
7 8 9
<BLANKLINE>
Grid
>>> print(sheet.grid)
Sheet Name: pyexcel
+------------+------------+------------+
| Column 1 | Column 2 | Column 3 |
+============+============+============+
| 1 | 2 | 3 |
+------------+------------+------------+
| 4 | 5 | 6 |
+------------+------------+------------+
| 7 | 8 | 9 |
+------------+------------+------------+
<BLANKLINE>
Mediawiki
>>> 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)
>>> book.save_as("myfile.mediawiki")
>>> myfile = open("myfile.mediawiki")
>>> print(myfile.read())
Sheet Name: Sheet 1
{| class="wikitable" style="text-align: left;"
|+ <!-- caption -->
|-
| align="right"| 1 || align="right"| 2 || align="right"| 3
|-
| align="right"| 4 || align="right"| 5 || align="right"| 6
|-
| align="right"| 7 || align="right"| 8 || align="right"| 9
|}
Sheet Name: Sheet 2
{| class="wikitable" style="text-align: left;"
|+ <!-- caption -->
|-
| X || Y || Z
|-
| 1.0 || 2.0 || 3.0
|-
| 4.0 || 5.0 || 6.0
|}
Sheet Name: Sheet 3
{| class="wikitable" style="text-align: left;"
|+ <!-- caption -->
|-
| O || P || Q
|-
| 3.0 || 2.0 || 1.0
|-
| 4.0 || 3.0 || 2.0
|}
<BLANKLINE>
>>> myfile.close()
Html
>>> book.save_as("myfile.html")
>>> myfile = open("myfile.html")
>>> print(myfile.read())
Sheet Name: Sheet 1
<table>
<tr><td style="text-align: right;">1</td><td style="text-align: right;">2</td><td style="text-align: right;">3</td></tr>
<tr><td style="text-align: right;">4</td><td style="text-align: right;">5</td><td style="text-align: right;">6</td></tr>
<tr><td style="text-align: right;">7</td><td style="text-align: right;">8</td><td style="text-align: right;">9</td></tr>
</table>
Sheet Name: Sheet 2
<table>
<tr><td>X </td><td>Y </td><td>Z </td></tr>
<tr><td>1.0</td><td>2.0</td><td>3.0</td></tr>
<tr><td>4.0</td><td>5.0</td><td>6.0</td></tr>
</table>
Sheet Name: Sheet 3
<table>
<tr><td>O </td><td>P </td><td>Q </td></tr>
<tr><td>3.0</td><td>2.0</td><td>1.0</td></tr>
<tr><td>4.0</td><td>3.0</td><td>2.0</td></tr>
</table>
<BLANKLINE>
Dependencies
tabulate
Change log
Planned
compactibility with pyexcel-io 0.2.0 and pyexcel 0.2.1
0.2.0 - 23.04.2016
It is a complete re-write of the whole extension.
Added
html support
support pyexcel 0.2.0’s generator output
pypy and pypy3 in test targets
support file stream and dot notation, e.g. pyexcel.Sheet.rst will return rst text representation of it.
Updated
#8, write_header as an option(False) to disable header writing
the json output of multiple sheet book will be sorted by its sheet names.
No longer, pyexcel-text is pyexcel-io plugin but pyexcel.sources plugin.
0.1.1 - 30.01.2016
Updated
#2, fix a typo in setup.py
0.1.0 - 17.01.2016
Updated
support pyexcel 0.2.0
0.0.3 - 12.06.2015
Updated
- #1, align api interface
with other pyexcel plugins, e.g. save_as, save_book_as
0.0.2 - 30.11.2014
Updated
support pyexcel 0.0.9
0.0.` - 20.11.2014
Initial release
Metadata
Release files for pyexcel-text 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pyexcel-text-0.2.0.zip | 12.4 kB | Details |
Release files / pyexcel-text-0.2.0.zip
| Download URL | pyexcel-text-0.2.0.zip |
|---|---|
| Size | 12.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0ab2ae8e07792c2feff3cf471de153653a6305d8088a30b600296ab2e55b731d
|
|
BLAKE2b-256 checksum How to use checksums |
b5bb1e583669ee3dc82d0878e6a64e83b1e39ab0ca7ae49f7a0536202f197585
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |