GithubHelp home page GithubHelp logo

Comments (4)

GoogleCodeExporter avatar GoogleCodeExporter commented on May 16, 2024
This should be Type-Enhancement, of course.

Original comment by [email protected] on 26 May 2009 at 4:20

from prettytable.

GoogleCodeExporter avatar GoogleCodeExporter commented on May 16, 2024
Sorry for the late response to this, Robert.  I haven't been checking the 
Issues tab
regularly because I assumed (incorrectly, it turns out) that I would get email
notifications about new issues.  Your enhancement request is a good one and I 
will
add it to my mental list of things to try out for PrettyTable 0.7.  Thanks!

Original comment by [email protected] on 4 Jun 2009 at 2:03

  • Added labels: Type-Enhancement
  • Removed labels: Type-Defect

from prettytable.

GoogleCodeExporter avatar GoogleCodeExporter commented on May 16, 2024
Hi,

I have just committed changes in response to Issue 10, which I think can be 
used to address your issue as well.  You can now use:

MyTable.float_format = "4.2"

to make sure that all floating point data in a table is printed using "%4.2f" 
formatting.  It is possible to use this to get an alignment by decimal.  If the 
largest floating point value in your table has, say, 5 digits in its 
non-decimal part, and you want to display floating point values with 2 digits 
after the decimal point, you could use a formatting string of 8.2 (the 8 comes 
from the maximum of 5 digits before the decimal point, plus 1 for the decimal 
point and then plus 2 for the digits after the point) and the result would look 
like this:

+--------------+
|    Values    |
+--------------+
|       2.35   |
|      61.88   |
|    1024.00   |
|   29109.60   |
|       3.14   |
+--------------+

Or you could use a formatting string of 08.2 to get leading 0s:

+--------------+
|    Values    |
+--------------+
|   00002.35   |
|   00061.88   |
|   01024.00   |
|   29109.60   |
|   00003.14   |
+--------------+

If this sort of approach meets the use case you had in mind (and you can 
remember that use case after me taking 3 years to act on this!), please let me 
know.  Or, if you had something else in mind, let me know that as well.

Original comment by [email protected] on 24 Mar 2012 at 3:04

from prettytable.

GoogleCodeExporter avatar GoogleCodeExporter commented on May 16, 2024
Given lack of negative feedback about this change for over one month, I am now 
closing the issue as "Fixed".  If the current implementation of aligning on 
decimal points turns out to have shortcomings, people should feel free to 
submit a new Issue.

Original comment by [email protected] on 1 May 2012 at 4:58

  • Changed state: Fixed

from prettytable.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.