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
0
votes
1 answer

How to sort Python's PrettyTable integer column correctly

We have a problem sorting a Population column. The issue is that PrettyTable reads all data from a CSV file as strings and sorts the integer values as strings. How to fix this? #!/usr/bin/python3 from prettytable import from_csv with…
Jan Bodnar
  • 10,969
  • 6
  • 68
  • 77
0
votes
2 answers

How to display title in pretty table in python?

I was trying to display the title in prettyTable but not sure what is wrong here - #!/usr/bin/python3 from prettytable import PrettyTable hostname = "abc.com" table = PrettyTable() table.title = hostname table.field_names = ['hostname',…
VIPIN KUMAR
  • 3,019
  • 1
  • 23
  • 34
0
votes
0 answers

Ping operation working perfectly in pycharm but not working in jupyter notebook

I have a piece of code that will ping 2 servers with a specific IP addresses mentioned in the code and it will list the time taken for the pings in the form of a prettytable. When i execute the same code in pycharm it is working fine .However if i…
0
votes
1 answer

Table borders not showing up in outlook desktop app but is visible in gmail and outlook when opened through browser

I need to send data to users in the form of table in a presentable format. I have the code which does it but unable to find why it doesnt show up on outlook desktop app. How can I work on it to ensure it works on outlook app as well? I have already…
mithraj
  • 3
  • 1
  • 2
0
votes
1 answer

Unable to import 'prettytable' in Python

I have up top of my script "from prettytable import PrettyTable." However, I get an error stating, "Unable to import 'prettytable.'" I have downloaded prettytable-0.7 and placed it in the directory, but still get the same error message.
Dan
  • 39
  • 3
  • 5
0
votes
0 answers

Print from PrettyTable with Python2 vs Python3

I am playing a little with PrettyTable in Python and I noticed completely different behavior in Python2 and Python 3. Can somebody exactly explain me the difference in output? Nothing in docs gave me satisfied answer for that. But let's start with…
Tatarinho
  • 754
  • 2
  • 11
  • 31
0
votes
1 answer

How to set Background to black and Foreground color to white in Prettytable?

I want to display tabular data using Prettytable where the background is black and foreground is white. I cannot use the HTML option. from prettytable import PrettyTable tbl = PrettyTable(header_color='\033[40m') tbl.field_names = ["col1", "col2",…
megjosh
  • 101
  • 1
  • 9
0
votes
1 answer

How to install prettytable in colab

I could not find other questions on that, if it is repeated just let me know please. I want to use prettytable on a colab notebook, but I don't know how to install it. Can anyone give the command line for that?
Victor Zuanazzi
  • 1,838
  • 1
  • 13
  • 29
0
votes
0 answers

How to write math symbols in prettytable?

I have the following prettytable headings: row[0] = ('k','No', 'A', 'I', 'P', 'lambda', 'rho','Wq', 'Est. Cost', 'Time (s)') t = PrettyTable(row[0]) In the above table, I want to write lambda, rho, and W^q in a math way. Is it possible here in the…
tcokyasar
  • 582
  • 1
  • 9
  • 26
0
votes
2 answers

Unable to install prettytable in anaconda

I want to install prettytable package in anaconda. To install this package with conda I have run: conda install -c synthicity prettytable and received the following error: (base) C:\Users\hp>conda install -c synthicity prettytable Solving…
Zara Khan
  • 134
  • 2
  • 16
0
votes
1 answer

Python: How to unpack dictionary keys as separate items rather than one item

When I run: from prettytable import PrettyTable as PTable accounts = { 'user1': 'pass1', 'user2': 'pass2' } table = PTable(['Day', [*accounts.keys()]]) #  creates empty table with headings print(table) My table looks like…
Redjman
  • 11
  • 2
0
votes
1 answer

How to make QPlainTextEdit look like a .txt file?

I have a QPlainTextEdit which shows some information in tabular form, and I added the option to save it as a .txt file. I built the table with prettytable. When I open the .txt file, it looks nice, just how I want it to look like. However, in my…
Jorge
  • 25
  • 7
0
votes
0 answers

Inserting Different length lists in PrettyTable Python

titles =('IP','URL') t = PrettyTable([]) list1 = ['8.8.8.8', '8.8.8.8', '8.8.8.8', '8.8.8.8', ] list2 = ['http://www.example.com', 'http://www.example.com', ] for title,lst in zip(titles,itertools.izip_longest(list1,list2,fillvalue="")): …
Anchal Raheja
  • 29
  • 2
  • 8
0
votes
2 answers

Error installing prettytable on ubuntu with pip

I just installed pip, installed a few packages np. I tried this pip install prettytable Collecting prettytable From cffi callback : Traceback (most recent call last): File…
quantumpotato
  • 9,637
  • 14
  • 70
  • 146
0
votes
1 answer

How can I import field names from a list or dictionary using prettytable in python

Every examples I saw the user knows the number and the names of columns. What if my field names are in a list or in a dictionary and I don't know the number of them? I read that the right code would be: t =…