Skip to content

Unhandled ZeroDivisionError Risk in wikipedia_report.py on Empty Data #301

Description

@pranjal2004838

Description

wikipedia_report.py has a potential crash due to ZeroDivisionError when processing empty language datasets. Specifically, if the CSV data file was successfully fetched but contained only headers (0 data rows)—which is a common edge case during API outages or schema changes—len(data) will evaluate to 0, causing the script to crash on division.:

Reproduction

  1. Run wikipedia_report.py where the corresponding Wikipedia CSV data file under data/ is empty or contains only headers (0 data rows).
  2. The script executes:
  3. Since len(data) is 0, a ZeroDivisionError is thrown.
  4. The reporting phase crashes entirely.

Expectation

The script should handle the case where the data rows are empty by defaulting the average to 0 and continuing to generate the report.

Environment

Software Version
Python 3.11
OS Windows / Linux / macOS

Metadata

Metadata

Type

No type

Fields

No fields configured for issues without a type.

Projects

Status
Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions