1

I saw that there are two libraries I can use: pyexcel_ods3 and pyexcel_ods. I tried to use

pyexcel_ods.Sheet("file.ods") 

and

pyexcel_ods.get_book(file_name="file.ods") 

but I got these errors:

AttributeError: module 'pyexcel_ods' has no attribute 'Sheet'

AttributeError: module 'pyexcel_ods' has no attribute 'get_book'

Could you help me?

Prateek Dewan
  • 1,587
  • 3
  • 16
  • 29
leob
  • 23
  • 4

1 Answers1

1

You probably made a mistake installing.

Check you have both pyexcel and pyexcel-ods:

pip install pyexcel pyexcel-ods

Try the following code:

from pyexcel import get_book

sheet = get_book(file_name="file_example_ODS_10.ods")
print(sheet)

(you can get a valid example file here https://file-examples.com/index.php/sample-documents-download/sample-ods-download/)

To get names:

from pyexcel import get_book

sheet = get_book(file_name="file_example_ODS_10.ods")
print(sheet.sheet_names())

Result:

['Sheet1']

Note that, in your example, you were trying to call get_book and Sheet directly on the pyexcel_ods module, while I only import pyexcel (and have the ods module installed) and that just works, pyexcel finds the module automatically when opening a .ods file.

Grismar
  • 27,561
  • 4
  • 31
  • 54
  • No... that's not the case. I'm trying to get the name of the sheet, like "Sheet1" – leob Jun 08 '20 at 19:24
  • If you get the two libraries I mention above, download the example file and try the code, you'll get exactly what you asked. – Grismar Jun 08 '20 at 22:29
  • The problem was: I was not using .sheet_names() method . Thank you! – leob Jun 09 '20 at 14:40