Nanda
Nanda

Reputation: 403

Column entries appear as NaN when converting an ODS file to EXCEL/CSV in Python

I am trying to convert an ODS file to XLSX/CSV using Python. The code snippet is shown below:

import odf
import pandas as pd
pd.read_excel("filename.ods")

The file gets converted to a Pandas data frame, however, all the column entries are NaN. Further, the column names appear as "unnamed 1", "unnamed 2", etc., instead of the column names contained in the original ODS file. Is there a way to resolve this issue?

A snapshot of the data is included below.

ODS file

Upvotes: 1

Views: 264

Answers (1)

Luuk
Luuk

Reputation: 14958

I created a (simple) example, and cannot reproduce the problem.

import odf
import pandas as pd 
xls = pd.read_excel("filename.ods",engine="odf")
xls.to_excel("filename.xlsx")

enter image description here

My conclusion (from this) is that more debugging info about your .ods file is needed to reproduce, and solve, this problem.

Upvotes: 0

Related Questions