From f33a4215739183cce3ba8d92af09d319dde64dba Mon Sep 17 00:00:00 2001 From: Josh Whittick <92024297+joshwhittick@users.noreply.github.com> Date: Mon, 21 Jul 2025 21:40:25 +0100 Subject: [PATCH] Update fetch-rates.py Check data is a list before trying to use it so it doesn't crash completely --- fetch-rates.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/fetch-rates.py b/fetch-rates.py index 4ad5bce21..b9362afe4 100644 --- a/fetch-rates.py +++ b/fetch-rates.py @@ -44,9 +44,15 @@ def fetch_all_data(): for n in range(1, 70): page_file = os.path.join(data_dir, f"coin_data_{n}.json") with open(page_file, "r", encoding="utf-8") as f: - data = json.load(f) - merged_data.extend(data) - + try: + data = json.load(f) + if isinstance(data, list): + merged_data.extend(data) + else: + print(f"Warning: {page_file} did not contain a list. Skipping.") + except json.JSONDecodeError: + print(f"Warning: {page_file} could not be decoded. Skipping.") + merged_data = [item for item in merged_data if item.get('current_price') is not None] with open(full_rates_file, "w", encoding="utf-8") as f: