diff --git a/.gitignore b/.gitignore index 9b847b2..1366b03 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ *~ .ve .ve2 +.DS_Store *.pyc __pycache__ .pytest_cache/ @@ -18,6 +19,7 @@ geckodriver.log ghostdriver.log cove/lib/org-ids.json cove/lib/org-ids.json.lock +lib360dataquality.egg-info/ chromedriver/ src/ node_modules/ diff --git a/.python-version b/.python-version new file mode 100644 index 0000000..e4fba21 --- /dev/null +++ b/.python-version @@ -0,0 +1 @@ +3.12 diff --git a/cove/cove_360/fixtures/badfile_missing_max_row.xlsx b/cove/cove_360/fixtures/badfile_missing_max_row.xlsx new file mode 100644 index 0000000..023fcd6 Binary files /dev/null and b/cove/cove_360/fixtures/badfile_missing_max_row.xlsx differ diff --git a/cove/cove_360/tests/test_browser.py b/cove/cove_360/tests/test_browser.py index 9b6506e..76ce95c 100644 --- a/cove/cove_360/tests/test_browser.py +++ b/cove/cove_360/tests/test_browser.py @@ -161,6 +161,9 @@ def server_url(request, live_server): 'than is supported by this tool (50000). Worksheets with too many rows: ' '\'grants\' (50001 rows), \'grants_2\' (50002 rows)' ], False), + ('badfile_missing_max_row.xlsx', [ + '', + ], True), ("dei_extension.xlsx", [ "do not use the 360Giving Data Standard codelists correctly.", ], True), diff --git a/cove/cove_360/views.py b/cove/cove_360/views.py index c65a0b8..dfaaacd 100644 --- a/cove/cove_360/views.py +++ b/cove/cove_360/views.py @@ -154,11 +154,12 @@ def explore_360(request, pk, template='cove_360/explore.html'): excessive_sheets = {} try: workbook = openpyxl.reader.excel.load_workbook(file_name, read_only=True) - excessive_sheets = { - sheetname: workbook[sheetname].max_row - for sheetname in workbook.sheetnames - if workbook[sheetname].max_row > settings.MAX_XLSX_ROWS - } + for sheetname in workbook.sheetnames: + ws = workbook[sheetname] + if not ws.max_row: + ws.calculate_dimension(force=True) + if ws.max_row > settings.MAX_XLSX_ROWS: + excessive_sheets[sheetname] = ws.max_row except (zipfile.BadZipFile, openpyxl.utils.exceptions.InvalidFileException): # Exceptions associated with invalid spreadsheets are passed through for cove to handle.