Commit 32c66e1f authored by SVN-Git Migration's avatar SVN-Git Migration

Imported Upstream version 0.7.2

parent 35633cca
########## PrettyTable 0.6.1 - June 03, 2012 ##########
* Unicode encoding scheme can now be set by user
* __str__ now uses user-specified encoding instead of ASCII. This
fixes a bug where tables with non-ASCII characters would print
correctly with "print x.get_string()" but not "print x" in 2.x
(thanks to Google Code user kevincobain2000 for reporting this
bug!)
* Fixed an incompatibility with 3.0 and 3.1 (html.escape was new
in 3.2)
########## PrettyTable 0.6 - April 05, 2012 ##########
########## PrettyTable 0.7 - Feb 17, 2013 ###########
* Improved Python 2 and 3 compatibility (2.4-3.2).
* Improved support for non-Latin characters. Table widths should
now be calculated correctly for tables with e.g. Japanese text.
* Table contents can now be read in from a .csv file
* Table contents can now be read in from a DB-API compatible cursor
* Table contents can now be read in from a string containing a
HTML table (thanks to Christoph Robbert for submitting this patch!)
* new valign attribute controls vertical alignment of text when
some cells in a row have multiple lines of text and others don't.
(thanks to Google Code user maartendb for submitting this patch!)
* hrules attribute can now be set to HEADER, which draws a rule only
under the header row
* new vrules attribute controls drawing of vertical rules and can
be set to FRAME, ALL or NONE
* new header_style attribute controls formatting of text in table
headers and can be set to "cap", "title", "upper", "lower" or None
* Fixed a simple bug regarding validation of max_width (thanks to
Anthony Toole for pointing out this bug and providing a patch).
* Fixed a simple bug regarding initialisation of int_format value
for new tables (thanks to Ingo Schmiegel for pointing out this
bug!)
* Fixed a bug regarding some constructor keywords, such as "border",
being ignored (thanks to Google Code user antonio.s.messina for
reporting this bug).
########## PrettyTable 0.6 - May 5, 2012 ##########
* Code is now simultaneously compatible with Python 2 and 3
* Replaced all setter methods with managed attributes
......
# Copyright (c) 2009-2012 Luke Maurits <luke@maurits.id.au>
# Copyright (c) 2009-2013 Luke Maurits <luke@maurits.id.au>
# All rights reserved.
# With contributions from:
# * Chris Clark
# * Christoph Robbert
# * Klein Stephane
# * "maartendb"
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
......
Metadata-Version: 1.0
Name: prettytable
Version: 0.6.1
Version: 0.7.2
Summary: A simple Python library for easily displaying tabular data in a visually appealing ASCII table format
Home-page: http://code.google.com/p/prettytable
Author: Luke Maurits
......@@ -9,6 +9,8 @@ License: BSD (3 clause)
Description: UNKNOWN
Platform: UNKNOWN
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 2.4
Classifier: Programming Language :: Python :: 2.5
Classifier: Programming Language :: Python :: 2.6
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
......
TUTORIAL ON HOW TO USE THE PRETTYTABLE 0.6 API
TUTORIAL ON HOW TO USE THE PRETTYTABLE 0.6+ API
*** This tutorial is distributed with PrettyTable and is meant to serve
as a "quick start" guide for the lazy or impatient. It is not an
......@@ -13,15 +13,15 @@ Let's suppose you have a shiny new PrettyTable:
from prettytable import PrettyTable
x = PrettyTable()
and you want to put some data into it. You have two (sane) options
and you want to put some data into it. You have a few options.
== Row by row ==
You can add data one row at a time. To do this you need to set the field names
first using the `set_field_names` method, and then add the rows one at a time
You can add data one row at a time. To do this you can set the field names
first using the `field_names` attribute, and then add the rows one at a time
using the `add_row` method:
x.set_field_names(["City name", "Area", "Population", "Annual Rainfall"])
x.field_names = ["City name", "Area", "Population", "Annual Rainfall"]
x.add_row(["Adelaide",1295, 1158259, 600.5])
x.add_row(["Brisbane",5905, 1857594, 1146.4])
x.add_row(["Darwin", 112, 120900, 1714.7])
......@@ -54,6 +54,39 @@ nicely as if you'd done it using just one of the two approaches. Tables built
this way are kind of confusing for other people to read, though, so don't do
this unless you have a good reason.
== Importing data from a CSV file ==
If you have your table data in a comma separated values file (.csv), you can
read this data into a PrettyTable like this:
from prettytable import from_csv
fp = open("myfile.csv", "r")
mytable = from_csv(fp)
fp.close()
== Importing data from a HTML string ==
If you have a string containing a HTML <table>, you can read this data into a
PrettyTable like this:
from prettytable import from_html
mytable = from_html(html_string)
== Importing data from a database cursor ==
If you have your table data in a database which you can access using a library
which confirms to the Python DB-API (e.g. an SQLite database accessible using
the sqlite module), then you can build a PrettyTable using a cursor object,
like this:
import sqlite3
from prettytable import from_db_cursor
connection = sqlite3.connect("mydb.db")
cursor = connection.cursor()
cursor.execute("SELECT field1, field2, field3 FROM my_table")
mytable = from_db_cursor(cursor)
== Getting data out ==
There are three ways to get data out of a PrettyTable, in increasing order of
......@@ -99,8 +132,9 @@ print(x)
in Python 3.x.
The old x.printt() method from versions 0.5 and earlier has been removed. To
pass options changing the look of the table, use the get_string() method
The old x.printt() method from versions 0.5 and earlier has been removed.
To pass options changing the look of the table, use the get_string() method
documented below:
print x.get_string()
......@@ -314,9 +348,11 @@ The options are these:
or not the first row of the table is a header showing the names of all the
fields.
* `hrules` - Controls printing of horizontal rules after rows. Allowed
values: FRAME, ALL, NONE - note that these are variables defined inside the
`prettytable` module so make sure you import them or use `prettytable.FRAME`
etc.
values: FRAME, HEADER, ALL, NONE - note that these are variables defined
inside the `prettytable` module so make sure you import them or use
`prettytable.FRAME` etc.
* `vrules` - Controls printing of vertical rules between columns. Allowed
values: FRAME, ALL, NONE.
* `int_format` - A string which controls the way integer data is printed.
This works like: print "%<int_format>d" % data
* `float_format` - A string which controls the way floating point data is
......@@ -390,7 +426,7 @@ exactly the same way as ASCII printing.
By default, PrettyTable outputs HTML for "vanilla" tables. The HTML code is
quite simple. It looks like this:
<table border="1">
<table>
<tr>
<th>City name</th>
<th>Area</th>
......@@ -437,7 +473,7 @@ x.print_html(attributes={"name":"my_table", "class":"red_table"})
will print:
<table border="1" name="my_table" class="red_table">
<table name="my_table" class="red_table">
<tr>
<th>City name</th>
<th>Area</th>
......
Metadata-Version: 1.0
Name: prettytable
Version: 0.6.1
Version: 0.7.2
Summary: A simple Python library for easily displaying tabular data in a visually appealing ASCII table format
Home-page: http://code.google.com/p/prettytable
Author: Luke Maurits
......@@ -9,6 +9,8 @@ License: BSD (3 clause)
Description: UNKNOWN
Platform: UNKNOWN
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 2.4
Classifier: Programming Language :: Python :: 2.5
Classifier: Programming Language :: Python :: 2.6
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
......
This diff is collapsed.
This diff is collapsed.
......@@ -7,6 +7,8 @@ setup(
version=version,
classifiers=[
'Programming Language :: Python',
'Programming Language :: Python :: 2.4',
'Programming Language :: Python :: 2.5',
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment