Working with Google Sheets

I am attempting to use Google Sheets from an app.

I have gone through the tutorial, api documentation and searched the forum, to try to figure out what is wrong with the following:

lib = app_files.my_library_ods
print('lib : ', lib)
print('lib.content_type : ', lib.content_type)
print('list(lib.worksheets) : ', list(lib.worksheets))

I am getting the following:

lib : ‘<‘Google Drive File: my library.ods’>’
lib.content_type : application/vnd.oasis.opendocument.spreadsheet
AttributeError: ‘File’ object has no attribute ‘worksheets’
at main, line 25

What am I missing?

Any help appreciated.

Looks like you need to convert the file to a google sheet before you can work with the google sheets api.

If you open it up in drive it should convert it for you, or give you the option to convert it.

Thank you.

This solved my problem.

I supose this means that if I use Drive to upload a file (.ods, .xls…), it must be converted before it will be recognised as a sheet, dispite its content_type?

1 Like