Comments (1)
If you were using github or git I'd submit a PR; but since you're using SVN
I've attached an updated copy of the prettytable.py. This version does two
things:
1. Enables my use case above by introducing a new function - print_table() -
that prints the lines to a file (default sys.stdout) instead of building them
into a list.
Instead of:
print(myprettytable)
You do:
myprettytable.print_table()
It also takes a file and end parameter like the print() does so callers can
redirect as desired.
2. Reduces memory significantly by using a generator - my test went from
11-12GB of RAM down to just under 7 GB of RAM usage.
The original get_string() was split into a few more functions to re-use the
code between the get_string() and print_table().
While this version works, and does a great job for the really big tables; it
could be further improved if the formatted data did not have to be saved.
prettytable_alternate.py is an attempt to use more generators to reduce memory.
Indeed it did work - peak was down to just over 5GB, and normal was around
4.7GB - but it also took a lot longer to output the data (it also had to format
the data twice due to the row generator). However, in both cases data is being
outputted earlier than the original implementation since it can be outputted
before all the data is completely built up.
Perhaps you have other ideas on how to speed this all up and reduce memory
consumption for the very large table variants.
Original comment by [email protected]
on 15 Dec 2014 at 11:35
Attachments:
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
- 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.