Jul-02-2021, 04:52 PM
(This post was last modified: Jul-02-2021, 04:52 PM by deanhystad.)
Not too simple, just odd. Ragged rows in a file is not that uncommon, but ragged columns is unusual. I don't see how this can be useful, but I think the code below produces the results you are asking for.
from itertools import islice data = iter([5, 77, 1, -4, 9, 17, 13, 2, 1, 5, 63, 8]) slices = [4, 2, 4, 1] columns = [list(islice(data, slice)) for slice in slices] for r in range(max(slices)): row = ['' if r >= len(column) else f'{column[r]}' for column in columns] print('\t'.join(row))