Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Write Dataframe into ODS format

I am reading a .xlxs file using pandas library and extracting the dataframe. Now I am trying to create a file with .ods extension and write the dataframe into it using pyexcel_ods library. Here is my code :--

import pandas as pd
from pyexcel_ods import save_data
from collections import OrderedDict

self.current_df = pd.read_excel('filename')
data = OrderedDict()
data.update(df)
save_data("as.ods", data)

It is throwing Error

{TypeError}'int' object is not iterable

Feel free to ask for more code.

Note :-- I am using Python 3.

like image 237
Soham Avatar asked Jun 09 '26 22:06

Soham


1 Answers

Please note that in recent versions of Pandas (current is 1.1) has been implemented support for ODS format in functions like pd.ExcelWriter() and pd.read_excel(). You only need to specify the propper engine "odf" to be able of working with OpenDocument file formats (.odf, .ods, .odt)

You will need the odfpy package installed.

like image 193
ragan Avatar answered Jun 12 '26 10:06

ragan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!