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, 2022 in Others by Kithuzzz
• 38,000 points
2,136 views

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, 2022 by narikkadan
• 63,600 points

Related Questions In Others

0 votes
1 answer

How to open an Excel file in C#?

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

answered Nov 13, 2022 in Others by narikkadan
• 63,600 points
1,255 views
0 votes
1 answer

How to convert an XML file to an Excel file?

Create a CSV file that is in ...READ MORE

answered Jan 3, 2023 in Others by narikkadan
• 63,600 points
1,597 views
0 votes
1 answer

How to scrape the specific text from kworb and extract it as an excel file?

The best practice to scrape tables is ...READ MORE

answered Feb 18, 2023 in Others by narikkadan
• 63,600 points
761 views
0 votes
1 answer

How to read an Excel CSV file in Python?

The csv module or the pandas library ...READ MORE

answered Mar 19, 2023 in Others by Kithuzzz
• 38,000 points
845 views
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 4,434 views
0 votes
1 answer
0 votes
1 answer

How to save a new sheet in an existing excel file, using Pandas?

import pandas as pd import numpy as np path ...READ MORE

answered Dec 10, 2022 in Others by narikkadan
• 63,600 points
7,523 views
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, 2022 in Others by narikkadan
• 63,600 points
8,047 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP