Python convert Excel File (xls or xlsx) to/from ODS

2024/10/3 10:35:44

I've been scouring the net to find a Python library or tool that can converts an Excel file to/from ODS format, but haven't been able to come across anything.

I need the ability to input and output data in either format. We don't need to worry about merged cells, formulas or anything non-straightforward.

Answer

If you have libreoffice installed, you can do a python execution wrapper around its headless mode:

$ /usr/bin/libreoffice --headless --invisible -convert-to ods /home/cwgem/Downloads/QTL_Sample_data.xls 
convert /home/cwgem/Downloads/QTL_Sample_data.xls -> /home/cwgem/QTL_Sample_data.ods using OpenDocument Spreadsheet Flat XML
$ /usr/bin/libreoffice --headless --invisible -convert-to xls /home/cwgem/QTL_Sample_data.ods 
convert /home/cwgem/QTL_Sample_data.ods -> /home/cwgem/QTL_Sample_data.xls using

Which would be a bit easier than trying to do it through the library route.

https://en.xdnf.cn/q/70740.html

Related Q&A

Select pandas frame rows based on two columns values

I wish to select some specific rows based on two column values. For example:d = {user : [1., 2., 3., 4] ,item : [5., 6., 7., 8.],f1 : [9., 16., 17., 18.], f2:[4,5,6,5], f3:[4,5,5,8]} df = pd.DataFrame(…

Using scipy sparse matrices to solve system of equations

This is a follow up to How to set up and solve simultaneous equations in python but I feel deserves its own reputation points for any answer.For a fixed integer n, I have a set of 2(n-1) simultaneous e…

Segmentation Fault in Pandas read_csv

I have Python 2.7.5 on Os X 10.9 with Pandas version 0.12.0-943-gaef5061. When I download this train.csv file and run read_csv, I get Segmentation Fault 11. I have experimented with the file encoding…

Multiple subprocesses with timeouts

Im using a recipe that relies on SIGALRM to set alarm interrupt -- Using module subprocess with timeoutThe problem is that I have more than one Python script using signal.ALARM process to set time-outs…

what is the difference between tfidf vectorizer and tfidf transformer

I know that the formula for tfidf vectorizer is Count of word/Total count * log(Number of documents / no.of documents where word is present)I saw theres tfidf transformer in the scikit learn and I just…

Use Pandas string method contains on a Series containing lists of strings

Given a simple Pandas Series that contains some strings which can consist of more than one sentence:In: import pandas as pd s = pd.Series([This is a long text. It has multiple sentences.,Do you see? M…

Is this the correct way of whitening an image in python?

I am trying to zero-center and whiten CIFAR10 dataset, but the result I get looks like random noise! Cifar10 dataset contains 60,000 color images of size 32x32. The training set contains 50,000 and tes…

Python zlib output, how to recover out of mysql utf-8 table?

In python, I compressed a string using zlib, and then inserted it into a mysql column that is of type blob, using the utf-8 encoding. The string comes back as utf-8, but its not clear how to get it bac…

Incorrect user for supervisord celeryd

I have some periodic tasks that I run with celery (daemonized by supervisord), but after trying to create a directory in the home dir for the user i setup for the supervisord process I got a "perm…

Pandas drop rows where column contains *

Im trying to drop all rows from this df where column DB Serial contains the character *:DB Serial 0 13058 1 13069 2 *13070 3 13070 4 13044 5 13042I am using:df = df[~df[DB Serial…