Print text tables for terminals
########################################################################## beautifultable ##########################################################################
.. inclusion-marker-badges-start
.. image:: https://badge.fury.io/py/beautifultable.svg :target: https://badge.fury.io/py/beautifultable
.. image:: https://img.shields.io/pypi/pyversions/beautifultable.svg :target: https://pypi.python.org/pypi/beautifultable/
.. image:: https://codecov.io/gh/pri22296/beautifultable/branch/master/graphs/badge.svg :target: https://codecov.io/gh/pri22296/beautifultable/branch/master/
.. image:: https://api.codacy.com/project/badge/Grade/7a76eb35ad4e450eaf00339e98381511 :target: https://www.codacy.com/app/pri22296/beautifultable?utm_source=github.com&utm_medium=referral&utm_content=pri22296/beautifultable&utm_campaign=Badge_Grade
.. image:: https://github.com/pri22296/beautifultable/actions/workflows/build.yml/badge.svg?branch=master :target: https://github.com/pri22296/beautifultable/actions/workflows/build.yml
.. image:: https://readthedocs.org/projects/beautifultable/badge/?version=latest :alt: Documentation Status :target: http://beautifultable.readthedocs.io/en/latest/?badge=latest
.. image:: https://img.shields.io/badge/Donate-PayPal-yellow.svg :target: https://paypal.me/beautifultable
.. inclusion-marker-badges-end
.. inclusion-marker-introduction-start
Introduction
This Package provides BeautifulTable class for easily printing tabular data in a visually appealing format to a terminal.
Features included but not limited to:
.. inclusion-marker-introduction-end
.. inclusion-marker-links-start
Links
Documentation <http://beautifultable.readthedocs.io/en/latest/>
_
Source <https://github.com/pri22296/beautifultable>
_
API Reference <http://beautifultable.readthedocs.io/en/latest/source/beautifultable.html#module-beautifultable>
_
.. inclusion-marker-links-end
.. inclusion-marker-usage-start
Usage
Here is an example of how you can use beautifultable::
>>> from beautifultable import BeautifulTable
>>> table = BeautifulTable()
>>> table.rows.append(["Jacob", 1, "boy"])
>>> table.rows.append(["Isabella", 1, "girl"])
>>> table.rows.append(["Ethan", 2, "boy"])
>>> table.rows.append(["Sophia", 2, "girl"])
>>> table.rows.append(["Michael", 3, "boy"])
>>> table.rows.header = ["S1", "S2", "S3", "S4", "S5"]
>>> table.columns.header = ["name", "rank", "gender"]
>>> print(table)
+----+----------+------+--------+
| | name | rank | gender |
+----+----------+------+--------+
| S1 | Jacob | 1 | boy |
+----+----------+------+--------+
| S2 | Isabella | 1 | girl |
+----+----------+------+--------+
| S3 | Ethan | 2 | boy |
+----+----------+------+--------+
| S4 | Sophia | 2 | girl |
+----+----------+------+--------+
| S5 | Michael | 3 | boy |
+----+----------+------+--------+
You can learn more about beautifultable at this Tutorial <http://beautifultable.readthedocs.io/en/latest/quickstart.html>
_
.. inclusion-marker-usage-end
.. inclusion-marker-install-start
Installation
::
python3 -m pip install beautifultable
.. inclusion-marker-install-end
.. inclusion-marker-changelog-start
Changelog
asdict
and aslist
method on the row object. (Thanks to @Agent-Hellboy <https://github.com/Agent-Hellboy>
_)from_csv
and to_csv
methods to export/import a csv file. (Thanks to @Agent-Hellboy <https://github.com/Agent-Hellboy>
_)from_df
and to_df
methods to export/import a dataframe. (Thanks to @Agent-Hellboy <https://github.com/Agent-Hellboy>
_)rows
and columns
to the BeautifulTable
class. Most of the existing
methods have been deprecated. Methods of the form {}_row
and {}_column
have been moved to
views rows.{}
and columns.{}
(ex. append_row
is now rows.append
). Calling older
deprecated methods will now raise a FutureWarning
. Special methods such as __len__
, __iter__
,
etc. have also been moved to the respective views. For details, refer the
API documentation and the Updated Tutorialborder
property can be accessed
to control all styling attributes affecting the border. Rest of the attributes can be accessed from
it's respective view.to_csv
and from_csv
to directly export/import to a
csv file. (Thanks to @dinko-pehar <https://github.com/dinko-pehar>
_)BeautifulTable.rows.filter
method to generate a new table with only certain rowsshape
attribute to the BeautifulTable
class which returns a tuple of form (nrow, ncol)BeautifulTable.columns.header.alignment
which can be used to have
a seperate header alignment. The default behaviour is to inherit BeautifulTable.columns.alignment
BeautifulTable.rows.sort
(earlier BeautifulTable.sort
) method to now
also accept any callables as a key.BeautifulTable.columns.width
(earlier BeautifulTable.column_widths
).
It no longer overrides user specified widths by default. You can reset it to default
by setting it to "auto"serialno
and serialno_header
. User can now easily implement
this functionality by using row headers if requiredget_table_width()
, copy()
and get_string()
.sign_mode
, numeric_precision
,
max_width
and renamed to sign
, precision
and maxwidth
respectivelyblessings
module was used to generate colored strings.__iter__
, __copy__
and __deepcopy__
which
should now work more reliably.@furlongm <https://github.com/furlongm>
_)table.column_alignments = beautifultable.ALIGN_LEFT
\n
character)intersect_{top|header|row|bottom}_{left|mid|right}
intersection_char
get_top_border()
, get_bottom_border()
, get_header_separator()
,
get_row_separator()
, auto_calculate_width()
column_width
is too lowdetect_numerics
boolean for toggling automatic numeric conversionserialno_header
column_count
was too highsort()
methodserialno
for auto printing serial numbersign_mode
related to str conversiondefault_padding
update_row
auto_calculate_width()
.. inclusion-marker-changelog-end
.. inclusion-marker-contribution-start
Contribute
If you have any suggestions or bug reports, Please create a Issue. Pull Requests are always welcome.
.. inclusion-marker-contribution-end
.. inclusion-marker-license-start
License
This project is licensed under the MIT License - see the LICENSE.txt <https://github.com/pri22296/beautifultable/blob/master/LICENSE.txt>
_ file for details.
.. inclusion-marker-license-end
.. inclusion-marker-donation-start
Donation
Love beautifultable? Consider supporting the development :)
.. image:: https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif :target: https://paypal.me/beautifultable
.. inclusion-marker-donation-end