OliverSherouse / wbdata

A python library for accessing world bank data
GNU General Public License v2.0
183 stars 54 forks source link

wbdata does not handle indicators with no data #76

Open EdGaere opened 6 months ago

EdGaere commented 6 months ago

Problem: Some indicators have no data but wbdata loops endlessly, incrementing the requested page on each request.

Example https://api.worldbank.org/v2/sources/85/indicators

Response

<wb:indicators page="1" pages="0" per_page="50" total="0"/>

Solution: early exit if WorldBank API returns pages=0

fetcher.py

def fetch(url, ..):
    while pages != this_page:
        ...
        if pages == 0: # early exit if WorldBank API returns pages=0
            break
OliverSherouse commented 6 months ago

Thanks for the report, I'll get that patched and try not to think about why they have indicators with no data.