The method get_data()
returns an instance of a OrderedDict
, where your keys represent the spreadsheet and the value of each key is a list of lists, representing the two-dimensional matrix formed by the cells of each spreadsheet.
For example, assuming your input sheet is something like:
Basic code:
from pyexcel_ods3 import get_data
planilha = get_data("entrada.ods")
print(planilha)
Exit:
OrderedDict([('Sheet1', [['foo', 'bar', 'baz'], ['aeiou', 'kwy', 'blah']]), ('Sheet2', [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12]])])
The instance of that OrderedDict
can be manipulated/modified at will and then saved again in file, see only:
from pyexcel_ods3 import get_data, save_data
# Carrega planilha
planilha = get_data("entrada.ods")
# Altera aleatoriamente o
# texto das celulas
planilha['Sheet1'][0][1] = 'bingo!'
planilha['Sheet1'][1][2] = 'kabum!'
planilha['Sheet1'][1][0] = 'shazam!'
# Multiplica por 2 todos os
# inteiros em todas a celulas
for linha in range(3):
for coluna in range(4):
n = planilha['Sheet2'][linha][coluna]
planilha['Sheet2'][linha][coluna] = n * 2
# Grava planilha modificada
save_data("saida.ods", planilha)
Exit:
Thanks for the tip Lacobus, in the previous morning I had managed to resolve using ezodf library, so I could percber the procedure is similar to what you indicated in the reply.
– lucas palheta