jazzband / tablib

Python Module for Tabular Datasets in XLS, CSV, JSON, YAML, &c.
https://tablib.readthedocs.io/
MIT License
4.61k stars 593 forks source link

How to not wrap columns? #471

Closed deeplook closed 2 years ago

deeplook commented 4 years ago

I'm looking for some way to output tables without wrapping cell content like in the attached example, but I can't see an option for it. Is there a way or a workaround?

Screenshot 2020-07-14 at 08 42 23
claudep commented 4 years ago

Hi @deeplook, the world is so small :smile:

Unfortunately, the export API for ReST doesn't support any column widths argument currently. However, you should be able to workaround this way:

from tablib.formats import registry
rst = registry.get_format('rst')
data = ...<prepare your data>...
rst.export_set_as_grid_table(data, column_widths=[12, 22, ...])

Does this suit your use case?

deeplook commented 4 years ago

😄

Yes, this would be much better. I could even do without the grid entirely, like a CSV with some max. column widths... I mean, it would be a few lines only to do without another package. 😄

claudep commented 4 years ago

Not sure, do you expect anything more from this ticket?

deeplook commented 4 years ago

I think it's ok. I have my own little function doing it. Providing generic params for alignment and column widths (incl. wrapping) might be worth to think of as feature for formats where it makes sense. Otherwise I'm fine with closing this. Thanks!