prettytable-rs
prettytable-rs copied to clipboard
Column macro
Hi @phsym,
I stumbled upon your crate for an application I'm writing and noticed that there isn't an easy way to create a table from columnar data. Have I missed this in the documentation, or is this yet to be implemented?
Thanks! Mandeep
Hi Mandeep, What do you mean exactly ? Are you try to create a table from a list of columns instead of a list of rows ?
Yep exactly that. Currently, I'm iterating through all of my vectors of data and adding the data to rows in the table. I'm not sure there is a time penalty for this, but I think being able to create columns would be a nice feature.
There's currently no way to do that in the library. But it could be nice indeed. I'm not sure there is a time penalty with what you do, since the Table struct is backed by a vector of rows. A methods to import from column data would probably do it the same way you do
this would be super useful.
Consider the case that you wish to display a table of data to the user, but allow them to specify which fields (columns, equivalently) to display. what would be the idiomatic way to construct a table such as this using this library?
Being able to construct a table by columns would make this trivial.
Perhaps a Vec<Row> type is not the best representation to use. Can ndarray offer a better solution?
even a Vec<Cell> would be more flexible. you'd track the number of rows and columns and roll your own modular arithmetic to do row/column/cell access.