Questions tagged [prettytable]

A simple Python library for easily displaying tabular data in a visually appealing ASCII table format.

PrettyTable is a simple Python library designed to make it quick and easy to represent tabular data in visually appealing ASCII tables. It was inspired by the ASCII tables used in the PostgreSQL shell psql.

PrettyTable allows for selection of which columns are to be printed, independent alignment of columns (left or right justified or centred) and printing of “sub-tables” by specifying a row range.

https://pypi.python.org/pypi/PrettyTable

155 questions
13
votes
2 answers

Python prettytable Sort by Multiple Columns

I'm using PrettyTable to print data to the terminal in a nice table format. It's pretty easy to print it ordered by a single column. from prettytable import PrettyTable table = PrettyTable(["Name", "Grade"]) table.add_row(["Joe",…
codeMonkey
  • 410
  • 1
  • 5
  • 13
10
votes
2 answers

How to use Pretty Table in Python to print out data from multiple lists?

I'm relatively new to Python Programming, using Python 3.x, and am working on a Barbershop P.O.S system where the admin will have the privilege to add Services and their corresponding Prices. I'm using the Pretty Table library to achieve printing…
mabishi
  • 115
  • 1
  • 1
  • 8
8
votes
1 answer

How to fix prettytable to display chinese character properly

from prettytable import PrettyTable header="乘客姓名,性别,出生日期".split(",") x =…
showkey
  • 482
  • 42
  • 140
  • 295
7
votes
2 answers

Python Pretty table with color output

I am using pretty table to generate tables output. Is it possible to generate in terms of colors. If failed it should display in red and its ok it should display in green. Code: from prettytable import PrettyTable a = "ok" b = "Failed" t =…
meteor23
  • 267
  • 3
  • 6
  • 11
7
votes
1 answer

Python PrettyTable: Add title above the table's header

I have a script which generates multiple tables, which all have the same column names and very similar data. Until now I've been making each table unique by printing a title before it, i.e.: print("Results for Method Foo") #table 1 print("Results…
istern
  • 363
  • 1
  • 4
  • 13
7
votes
2 answers

Add multiple line in python single table cell

I am not sure how to draw a table like as below, I tried using prettytable but not able to put multiple line in one cell. NB: Number of lines should be based on the number of the string, so I want to put some n string per line. Could some one…
James Sapam
  • 16,036
  • 12
  • 50
  • 73
6
votes
2 answers

How can I define the width of a column (PrettyTable, Python)?

So, I got a table (PrettyTable) and I want to make them as wide as I want. For example, the first column should have a width of 5px, the second of 18px, and so on... How can I do this?
einmalundweg
  • 83
  • 1
  • 6
6
votes
3 answers

How to get the value of a cell when using prettytable

Is it possible to get the value of a specific cell when using prettytable? I have the following code to iterate through all rows of a simple table. from prettytable import PrettyTable table = PrettyTable(["Column 1", "Column 2", "Column…
Christian Berendt
  • 3,416
  • 2
  • 13
  • 22
6
votes
4 answers

How do I save table from prettytable?

So I am using the library 'prettytable' and am able to get a table of my data printed upon execution. However, I have no idea how to save it to a file. Ideally I'd like the table to be saved in a pdf so I could use it for my report. Here is an…
user2869276
  • 149
  • 1
  • 3
  • 10
4
votes
2 answers

Change cell color if the two values of this cell have opposite signs in Pretty tables in Julia

How to change cell color if the two values of this cell have opposite signs in Pretty tables in Julia below is my code and the table is attached. names = string.(-1/1:1/4:1/1) pretty_table(AStrings , header = ([-1,-3/4, -1/2, -1/4, 0, 1/4, 1/2, 3/4,…
Hana
  • 101
  • 5
4
votes
2 answers

Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './lib/sync' is not defined by "exports" in node_modules\csv-parse\package.json

Whenever I run index.js in nodejs I get this error message. Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './lib/sync' is not defined by "exports" in D:\Scuola\5f_Informatca\Tpsit\Telegram\node_modules\csv-parse\package.json at new…
4
votes
2 answers

How to make Images/PDF of Timetable using Python

I am solving a timetable scheduling problem and wants to print out the Final Output in the form of PDF or set of images. I have multiple sections and each section has its own schedule. I have created a 2D array for each section. The array is of 5 x…
Awais Shahid
  • 117
  • 4
  • 15
4
votes
4 answers

Convert Python Pretty table to CSV using shell or batch command line

Whats an easy way convert the output of Python Pretty table to grammatically usable format such as CSV. The output looks like this : C:\test> nova list …
CodeEmpower
  • 635
  • 1
  • 11
  • 29
3
votes
0 answers

How to merge columns in a table of PrettyTable? (Python)

With this code: from prettytable import PrettyTable x= PrettyTable() x.field_names = ["City name", "Area", "Population", "Annual Rainfall"] x.add_row(["Adelaide", 1295, 1158259, 600.5]) print(x) Prints the…
Eduardo Herrera
  • 201
  • 1
  • 7
3
votes
1 answer

Using PrettyTable in python with clickable html links as a column

I am creating a table in python using pretty-table and trying to have one column which are the urls have clickable links: Eg: filepath = "pretty_table.html" from prettytable import PrettyTable x = PrettyTable() x.format = True x =…
Jason
  • 2,246
  • 6
  • 34
  • 53
1
2 3
10 11