prettytable-rs icon indicating copy to clipboard operation
prettytable-rs copied to clipboard

Column macro

Open mandeep opened this issue 9 years ago • 4 comments

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

mandeep avatar Nov 24 '16 19:11 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 ?

phsym avatar Nov 26 '16 14:11 phsym

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.

mandeep avatar Nov 26 '16 17:11 mandeep

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

phsym avatar Nov 26 '16 18:11 phsym

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.

danieleades avatar Nov 07 '20 11:11 danieleades