Comments (7)
Agreed.
Original comment by [email protected]
on 21 Mar 2012 at 5:30
from prettytable.
Hi,
Thanks for the suggestion. I agree that this would be a nice feature, and it
doesn't seem too hard. I will have a go at implementing it shortly. For now
I'll probably just go with one format spec for all columns rather than a
per-column setting, just because I have a lot of feature requests which have
piled up and I want to try to make fast progress on them. But upgrading to a
per-column setting later is a definite possibility.
Cheers,
Luke
Original comment by [email protected]
on 23 Mar 2012 at 3:55
- Changed state: Accepted
- Added labels: Type-Enhancement
- Removed labels: Type-Defect
from prettytable.
Hi,
I have just committed to the trunk of the svn repo with an implementation of
this. I would appreciate it very much if the people who have commented on this
issue could give the new version a test and confirm whether or not it meets
their needs. Note, however, that if you have been using PrettyTable 0.5 until
now, the API in the trunk version is substantially different. Check out this
Wiki page for instructions on how the new, cleaner API works:
http://code.google.com/p/prettytable/wiki/Tutorial06
To set a floating point format for a PrettyTable object, just use:
MyTable.float_format = "4.2"
to print things using "%4.2f". You can also do 04.2 to pad with leading 0s,
etc.
Original comment by [email protected]
on 24 Mar 2012 at 2:53
from prettytable.
Working well for me. Thanks for adding the feature. Per-column formats would
be great.
Original comment by [email protected]
on 27 Mar 2012 at 12:47
from prettytable.
Per-column formatting is now supported in the trunk version. It works like
this:
table.float_format["Foo"] = "4.2"
table.float_format["Bar"] = "2.4"
table.float_format["Baz"] = "123.321"
If you try to use the old style syntax and do:
table.float_format = "4.2"
then this will set a format of "4.2" to all columns, over-writing any
per-column formatting you previously set up.
If you are interested in per-column formatting, please try to give this a test
soon. If I do not hear of any bugs with the new per-column formatting in a few
days I will close this ticket, since I'm trying to get a clean Issue page to
release 0.6, and people will have to open a new one to report bugs.
Original comment by [email protected]
on 1 May 2012 at 4:54
from prettytable.
Forgot to mention - there is now similar support for integer formatting strings
with the same interface as float formatting, e.g.
table.int_format["Foo"] = "05"
will print any integer data in the "Foo" column padded out to 5 characters with
leading zeros.
Original comment by [email protected]
on 1 May 2012 at 4:59
from prettytable.
Closing this issue since float formatting is now implemented and available on a
per-column basis, and I've received no bug reports or negative feedback. If
anybody has float formatting requirements in the future which PrettyTable
doesn't support, feel free to open a new ticket.
Original comment by [email protected]
on 4 May 2012 at 6:18
- Changed state: Fixed
from prettytable.
Related Issues (20)
- the data on "how to display chinese character"
- how to display "ambiguous" width in chinese character?
- table.min_width is broken when using PLAIN_COLUMNS style HOT 2
- Field alignment error when using "blessings" module HOT 1
- Adding colors to column values messes up the spacing HOT 2
- Setting float_format in **kwargs does not actually affect output - confusing behavior HOT 1
- Permissions are incorrect HOT 1
- Add date formatting for datetime etc instances HOT 3
- In get_string, end is eval before sortby
- HTML output is lacking borders, alignment
- Cannot print unicode characters, for example: degree symbol °
- Pandas DataFrame Table Factory HOT 3
- Upload new version to pypi
- xterm reset escape sequence not filtered HOT 2
- Support large tables in output HOT 1
- Prettytable 0.7.2 does not handle rowspan correctly
- Creating a PrettyTable inside a for. HOT 1
- Project Future and Plans HOT 5
- Export project to Github (or other git hosting project) HOT 2
- Stretching columns when the data are longer than the header
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from prettytable.