Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uploading new XLSForms fails #146

Closed
jnm opened this issue Sep 29, 2021 · 1 comment · Fixed by #147
Closed

Uploading new XLSForms fails #146

jnm opened this issue Sep 29, 2021 · 1 comment · Fixed by #147
Assignees
Labels

Comments

@jnm
Copy link
Member

jnm commented Sep 29, 2021

class Converter(object):
def set_excel(self, io):
self.sheets = pd.read_excel(io, sheetname=None)

https://sentry.kbtdev.org/organizations/kobo/issues/430546/

TypeError: read_excel() got an unexpected keyword argument 'sheetname'
  File "django/core/handlers/exception.py", line 47, in inner
    response = get_response(request)
  File "django/core/handlers/base.py", line 181, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "django/contrib/admin/options.py", line 616, in wrapper
    return self.admin_site.admin_view(view)(*args, **kwargs)
  File "django/utils/decorators.py", line 130, in _wrapped_view
    response = view_func(request, *args, **kwargs)
  File "django/views/decorators/cache.py", line 44, in _wrapped_view_func
    response = view_func(request, *args, **kwargs)
  File "django/contrib/admin/sites.py", line 232, in inner
    return view(request, *args, **kwargs)
  File "django/contrib/admin/options.py", line 1655, in add_view
    return self.changeform_view(request, None, form_url, extra_context)
  File "django/utils/decorators.py", line 43, in _wrapper
    return bound_method(*args, **kwargs)
  File "django/utils/decorators.py", line 130, in _wrapped_view
    response = view_func(request, *args, **kwargs)
  File "django/contrib/admin/options.py", line 1538, in changeform_view
    return self._changeform_view(request, object_id, form_url, extra_context)
  File "django/contrib/admin/options.py", line 1584, in _changeform_view
    self.save_model(request, new_object, form, not add)
  File "django/contrib/admin/options.py", line 1097, in save_model
    obj.save()
  File "equitytool/models.py", line 29, in save
    self.csv_form = xls2csv(self.xls_form, **settings)
  File "equitytool/xls2csv.py", line 29, in xls2csv
    c.set_excel(io)
  File "equitytool/xls2csv.py", line 8, in set_excel
    self.sheets = pd.read_excel(io, sheetname=None)
  File "pandas/util/_decorators.py", line 299, in wrapper
    return func(*args, **kwargs)
@jnm jnm added the bug label Sep 29, 2021
@jnm jnm self-assigned this Sep 29, 2021
@jnm
Copy link
Member Author

jnm commented Sep 29, 2021

Removed sheetname=None keyword argument; result: Your version of xlrd is 2.0.1. In xlrd >= 2.0, only the xls format is supported. Install openpyxl instead.

Installed openpyxl; got a KeyError at

  File "/app/equitytool/xls2csv.py", line 11, in set_settings
    settings = self.sheets['settings']

sheetname=None was important after all, but it seems to have been renamed in Pandas to sheet_name 😒

Specify None to get all sheets.

Replacing with sheet_name=None seems to work.

jnm added a commit that referenced this issue Sep 29, 2021
…and tolerate XLSForm uploads that do not contain settings sheets.
Fixes #146
@jnm jnm closed this as completed in #147 Sep 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant