Is there script language for calc?

I create lots of(50+) *.xls file by C++ , if these files are read directly by pandas, like this
df = pd.read_excel(’./1.xls’)
it is not possible, if 1.xls is opened and than save as 2.xls manually, pandas can read 2.xls well.

so I want to use calc script to do this job , open an *.xls file, and save as another xls file ,how to write calc script ?

import shutil
shutil.copyfile('1.xls', '2.xls')


it doesn’t work

May be you should describe one or two bits more verbose what you are doing and what exactly doesnt work

I write the code as your post, the size of 2.xls is the same as 1.xls,
df = pd.read_excel(’./2.xls’) not work

when I open the 1.xls genereated by c++, the calc prompts information as attached picture

using default setting of calc, save opened xls file as 2.xls, 2.xls has larger size than 1.xls

the initila 1.xls lacks some information needed by calcs, I guess

Let me try to phrase the question as I understand it.

“I create XLS files using some C++ code (some library?); and the resulting XLS files can’t be opened in Pandas (likely, the generated XLS files are somehow defective). So I want LibreOffice to fix them for me; what can I do to have LibreOffice open and save all the generated XLS files?”

I’d use:

soffice --convert-to xls --outdir /path/to/outdir /path/to/indir/*.xls

And I’d definitely file a bug against the used C++ library.

using C++ ofsteam
std::ofstream Fs(“1.xls”);
if (!Fs.is_open()) {
std::cout << “error!” << std::endl;

That is not an XLS. That is a CSV. And pandas should use read_csv for that.

1 Like

Thanks for your reminding, its csv file, it’s wrong that I think its an xls file

soffice --headless --convert-to xlsx --infilter=“csv:9,59,34,UTF8” 1.csv
This works for me, 9 is ASCII value of \t

again … pandas can read .csv and also it is able to write xlsx

1 Like

yes, I change pd.read_excel() to pd.read_csv()