-
-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[feature Request] Support for row with less columns #59
Comments
It's not so clear what the default behavior should be when the number of columns does not match. There should ideally be an API for choosing which columns get merged in each row since in other cases you may want different cells to be merged into one, and not always just all the cells until the end of the row. It's hard to come up with a very customizable interface that's also simple to use. One solution could be to have a unique value to represent merging with the cell on the left, eg. table2ascii(
body=[
[1, 2, 3, 4, 5],
["A", "Long cell value", MERGE_LEFT, MERGE_LEFT, MERGE_LEFT ]
]
) I'm not sure how common the use case is, let me know what your thoughts are on how it should be implemented for the user. |
I think your example case is pretty neat. |
I've created a branch at https://github.com/DenverCoder1/table2ascii/tree/merge with what I've tried out. You should be able to test it with For your example, it should work just fine. from table2ascii import table2ascii
from table2ascii.merge import Merge
from table2ascii.alignment import Alignment
from table2ascii.preset_style import PresetStyle
output = table2ascii(
header=["Name", "Price", "Category", "Stock", "Sku"],
body=[
["test", 443, "test", 67, "test"],
],
footer=["Description", "Long cell value that is merged", Merge.LEFT, Merge.LEFT, Merge.LEFT],
alignments=[Alignment.LEFT] * 5,
style=PresetStyle.thin_thick_rounded,
)
print(output) output = table2ascii(
header=["Name", "Price", "Category", "Stock", "Sku"],
body=[
["test", 443, "test", 67, "test"],
],
footer=["Description", "Long cell value that is merged and wraps to multiple lines", Merge.LEFT, Merge.LEFT, Merge.LEFT],
alignments=[Alignment.LEFT] * 5,
style=PresetStyle.thin_thick_rounded,
) After some more testing, it will likely make it into the next release. |
This feature is now released in version 1.0.1 |
Thanks, This may be the only one program in this category which allows this. Thanks again for considering my request. I honor you. |
if first row has 3 all rows have to have 3 columns. Is it possible to add a new row with 2 columns? currently not. in future?
Here the last row, has two columns: Description and
i edited the text to show.
The text was updated successfully, but these errors were encountered: