Python Forum
Modify LibreOffice's ods spreadsheet - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Modify LibreOffice's ods spreadsheet (/thread-37719.html)



Modify LibreOffice's ods spreadsheet - Pavel_47 - Jul-13-2022

Hello,

Here is a snippet on how to access rows in the worksheet.
The type of the "rows" object is odict_values.
Converting it to a list (i.e. list(rows)) results in a list within a list, e.g. [[['aaa', 'rrr'], ['bbb', 'ztutrutr'], ['cccc', 'zuzu'], ['ddd']]].
Is there a smart way to access spreadsheet content to avoid quite large list processing.
Thanks.

from pyexcel_ods3 import save_data
from pyexcel_ods3 import get_data
path = '/.../test.ods'
data_in = get_data(path)
rows = data_in.values()
for row in rows:
    print(row)