This Package provides BeautifulTable class for easily printing tabular data in a visually appealing format to a terminal.
Features included but not limited to:
- Full customization of the look and feel of the table
- Build the Table as you wish, By adding rows, or by columns or even mixing both these approaches.
- Full support for colors using ANSI sequences or any library of your choice. It just works.
- Plenty of predefined styles for multiple use cases and option to create custom ones.
- Support for Unicode characters.
- Supports streaming table when data is slow to retrieve.
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
python3 -m pip install beautifultable
- Drop support for Python 3.4, 3.5 and 3.6
- Add official support for python 3.9 and 3.10
- Added asdict and aslist method on the row object. (Thanks to @Agent-Hellboy)
- Added from_csv and to_csv methods to export/import a csv file. (Thanks to @Agent-Hellboy)
- Added from_df and to_df methods to export/import a dataframe. (Thanks to @Agent-Hellboy)
- Fixed an issue where appending a column with a header to an empty table left the table instance in an inconsistent state.
- Added two new views
rows
andcolumns
to theBeautifulTable
class. Most of the existing methods have been deprecated. Methods of the form{}_row
and{}_column
have been moved to viewsrows.{}
andcolumns.{}``(ex. ``append_row
is nowrows.append
). Calling older deprecated methods will now raise aFutureWarning
. Special methods such as__len__
,__iter__
, etc. have also been moved to the respective views. For details, refer the API documentation and the Updated Tutorial - The existing styling attributes have also been deprecated. A new
border
property can be accessed to control all styling attributes affecting the border. Rest of the attributes can be accessed from it's respective view. - Added support for row headers. As a result rows can now be accessed by their keys similar to columns
- Added two new methods
to_csv
andfrom_csv
to directly export/import to a csv file. (Thanks to @dinko-pehar) - Added
BeautifulTable.rows.filter
method to generate a new table with only certain rows - Added a new
shape
attribute to theBeautifulTable
class which returns a tuple of form (nrow, ncol) - Added new attribute
BeautifulTable.columns.header.alignment
which can be used to have a seperate header alignment. The default behaviour is to inheritBeautifulTable.columns.alignment
- Updated
BeautifulTable.rows.sort
(earlierBeautifulTable.sort
) method to now also accept any callables as a key. - Updated behaviour of
BeautifulTable.columns.width
(earlierBeautifulTable.column_widths
). It no longer overrides user specified widths by default. You can reset it to default by setting it to "auto" - Deprecated attribute
serialno
andserialno_header
. User can now easily implement this functionality by using row headers if required - Deprecated methods
get_table_width()
,copy()
andget_string()
. - Deprecated constructor arguments and class attributes named
sign_mode
,numeric_precision
,max_width
and renamed tosign
,precision
andmaxwidth
respectively - Fixed an issue where table was malformed if
blessings
module was used to generate colored strings. - Fixed issues with the existing implementation of
__iter__
,__copy__
and__deepcopy__
which should now work more reliably. - Fixed an issue where default padding could not be set to 0. (Thanks to @furlongm)
- Fixed several memory leak issues by ensuring that all internal objects hold only a weak reference to the table instance.
- Dropped support for Python 2
- Dropped support for Python 3.3
- Added support for streaming tables using a generator for cases where data retrieval is slow
- Alignment, padding, width can now be set for all columns using a simplified syntax like
table.column_alignments = beautifultable.ALIGN_LEFT
- Added 4 new styles, STYLE_BOX, STYLE_BOX_DOUBLED, STYLE_BOX_ROUNDED, STYLE_GRID.
- Renamed STYLE_RESTRUCTURED_TEXT to STYLE_RST
- wcwidth is now an optional dependency
- Updated the algorithm for calculating width of columns(better division of space among columns)
- Added support for Paragraphs(using
\n
character) - Added finer control for intersection characters using 12 new
attributes
intersect_{top|header|row|bottom}_{left|mid|right}
- Added the ability to also accept bytestrings instead of unicode
- Deprecated attribute
intersection_char
- Deprecated methods
get_top_border()
,get_bottom_border()
,get_header_separator()
,get_row_separator()
,auto_calculate_width()
- Fixed an issue with WEP_ELLIPSIS and WEP_STRIP when using multibyte characters
- Fixed an issue where table would not be in proper form if
column_width
is too low
- Added support for handling Multi byte strings
- Added support for colored strings using ANSI escape sequences
- Added constraint where all strings must be unicode
- Fixed an issue where sometimes width was calculated as higher than intended
- Added support for handing color codes using ANSI escape sequences(experimental)
- Fixed collections ABCs deprecation warning
- Added new style STYLE_NONE
- Fixed issue regarding improper conversion of non-string floats
- Added
detect_numerics
boolean for toggling automatic numeric conversion
- Added new property
serialno_header
- Deprecated methods with misspelled "seperator" in their name.
- Fixed an issue where table was corrupted when
column_count
was too high
- Added predefined styles for easier customization
- Added reverse argument to
sort()
method - Fixed enum34 dependency for python versions prior to 3.4
- Added property
serialno
for auto printing serial number - Fixed an issue with
sign_mode
related to str conversion - Fixed bugs related to python version prior to 3.3
- Fixed exception on WEP_ELLIPSIS and token length less than 3
- Fixed printing issues with empty table
- Added python 2 support
- Fixed minor issues
- Added new property
default_padding
- Added new method
update_row
- Fixed an issue in
auto_calculate_width()
- Initial release on PyPI
If you have any suggestions or bug reports, Please create a Issue. Pull Requests are always welcome.
This project is licensed under the MIT License - see the LICENSE.txt file for details.
Love beautifultable? Consider supporting the development :)