Open AtomicNess123 opened 3 years ago
You could do something like this. You would have to decide on how you would treat existing line breaks within the cell:
def wrap_cell(cell, w):
from textwrap import wrap
rv = []
for i in cell.splitlines():
rv.extend(wrap(i, w))
return '\n'.join(rv)
>>> lines = wrap_cell('this is a long piece of text'
' that we want to change by wrapping it '
'into shorter lines\nand this was the second line',20)
>>> print(lines)
this is a long piece
of text that we want
to change by
wrapping it into
shorter lines
and this was the
second line
Is this possible? THanks.