Skip to content

Commit

Permalink
update to openpyxl-based itertable
Browse files Browse the repository at this point in the history
  • Loading branch information
sheppard committed Nov 19, 2021
1 parent 0b6e627 commit 5cb31c9
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ jobs:
python -m pip install flake8 wheel
python -m pip install django==${{ matrix.django-version }}
python -m pip install djangorestframework==${{ matrix.drf-version }}
python -m pip install itertable natural-keys html-json-forms
python -m pip install python-dateutil xlrd==1.2.0
python -m pip install natural-keys html-json-forms
python -m pip install git+https://github.com/wq/itertable.git
- name: Install celery & redis
if: ${{ matrix.backend == 'celery' }}
run: python -m pip install celery redis
Expand Down
9 changes: 8 additions & 1 deletion data_wizard/tasks.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from xlrd import colname
from collections import OrderedDict
from .models import Identifier
from .signals import import_complete, new_metadata
Expand Down Expand Up @@ -49,6 +48,14 @@ def get_id(obj, field):
return field.to_representation(obj)


def colname(i):
if i >= 26:
q, r = divmod(i, 26)
return colname(q - 1) + colname(r)
else:
return chr(ord('A') + i)


@wizard_task(label="Processing Data", url_path="auto", use_async=True)
def auto_import(run):
"""
Expand Down
6 changes: 3 additions & 3 deletions tests/test_numbers.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ def test_xlsx_zipcode_default(self):
],
)

# Records imported, but with '.0' due to XLSX number parsing
# xlrd would include '.0' in number, but openpyxl does not
self.assert_records(
run,
[
"Imported 'Minneapolis 55455.0' at row 1",
"Imported 'Chicago 60611.0' at row 2",
"Imported 'Minneapolis 55455' at row 1",
"Imported 'Chicago 60611' at row 2",
],
)

Expand Down

0 comments on commit 5cb31c9

Please sign in to comment.