Commit 87ef3c6c authored by Bruno Duyé's avatar Bruno Duyé

Download: fix --limit_nb_tables that was broken

parent babe1984
......@@ -103,12 +103,14 @@ def main():
tables_list = get_from_api(tables_list_url)
# Get available frequencies for this dataset
dataset_frequencies = get_from_api(API_URLs['series_frequencies'].format(api_user_id=api_user_id, dataset_code=dataset_code))['ParamValue']
nb_tables_donwloaded = 0
nb_tables_downloaded = 0
# For each "table" (set of series)
for table_info in tables_list["ParamValue"]:
table_name = table_info['TableName']
log.debug("* {}".format(table_name))
# Download series data and write series file
if args['--limit_nb_tables'] and nb_tables_downloaded >= int(args['--limit_nb_tables']):
break
for frequency_dict in dataset_frequencies:
frequency_code = frequency_dict['FrequencyID']
url = API_URLs['series_data'].format(api_user_id=api_user_id, dataset_code=dataset_code, table_name=table_name, frequency_code=frequency_code)
......@@ -116,9 +118,7 @@ def main():
json = get_from_api(url, raise_on_errors=False)
if json:
write_json_file(table_filepath, json)
nb_tables_donwloaded += 1
if args['--limit_nb_tables'] and nb_tables_donwloaded == int(args['--limit_nb_tables']):
break
nb_tables_downloaded += 1
log.info('END')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment