How to update an existing excel ods file

0 votes

Once I've read data from an.xls file sheet. Without making any other changes to the excel file, I want to add that data to a sheet in an existing file with the .ods extension. Openpyxl was my first choice, but it does not support it.ods files. I then tried pyexcel-ods3, but I am still unsure of how to use it to update an existing .ods file.

This is the code I tried but it's for writing a new .ods excel file and not for updating an existing one.

from pyexcel_ods3 import save_data

data = OrderedDict()  # from collections import OrderedDict
data.update({"Sheet 1": [[1, 2, 3], [9, 5, 6]]})
data.update({"Sheet 2": [["row 1", "row 2", "row 3"]]})
save_data("your_file.ods", data)

I tried finding the code for updating in the pyexcel-ods3 doc but could not find anything. If pyexcel-ods3 contains a code for it, do let me know. In addition, if a new package can complete this work, I'm willing to try it. The Python version I'm using is 3.9.1.

Oct 7 in Others by Kithuzzz
• 20,660 points

1 answer to this question.

0 votes

It cannot be altered unless the original file is loaded. If you save a file with the name of a file that already exists, the library will not recognize that you want to alter the existing file and will overwrite it.

You must load a file, maybe reconstruct its structure in memory, make your changes, and then save it back to the filesystem in order to modify it. 

The relevant piece of code from the link you posted is:

from pyexcel_ods3 import get_data

data = get_data("your_file.ods")

You can find that section here.

answered Oct 8 by narikkadan
• 37,660 points

Related Questions In Others

0 votes
1 answer

How to import excel file in Oracle SQL live

Hello, there are a few steps You'll ...READ MORE

answered Feb 18 in Others by gaurav
• 22,040 points
0 votes
1 answer

How to generate the "create table" sql statement for an existing table in postgreSQL

Create a table for a demo: CREATE TABLE ...READ MORE

answered Jun 20 in Others by nisha
• 2,190 points
0 votes
1 answer

How to print an Excel Sheet using VBA with Nitro PDF Creator in Excel 2016

you can use the built-in excel facilities ...READ MORE

answered Sep 24 in Others by narikkadan
• 37,660 points
0 votes
1 answer

How to recover corrupted excel file

If it were just corrupted then you ...READ MORE

answered Sep 30 in Others by narikkadan
• 37,660 points
0 votes
2 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 3,140 views
0 votes
1 answer
0 votes
1 answer

How to find out how many rows and columns to read from an Excel file with PHPExcel?

Solution: $file_name = htmlentities($_POST['file_name']); $sheet_name = htmlentities($_POST['sheet_name']); $number_of_columns = htmlentities($_POST['number_of_columns']); $number_of_rows ...READ MORE

answered Oct 23 in Others by narikkadan
• 37,660 points
0 votes
1 answer

How to open an Excel file in C#?

You must have Microsoft Visual Studio Tools ...READ MORE

answered Nov 13 in Others by narikkadan
• 37,660 points
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP