Skip invalid entries

This commit is contained in:
IshaVenikar 2025-06-03 12:38:12 +05:30
parent 7292d97674
commit 0be9dd8f90
2 changed files with 9 additions and 1 deletions

View File

@ -4,6 +4,7 @@ import pandas as pd
import json
import re
import argparse
from bech32 import bech32_decode
def get_excel_download_url(google_sheet_url):
"""
@ -57,6 +58,13 @@ def convert_excel_to_json(excel_path, json_path, sheet_name):
if not key or key.lower() == 'nan':
continue
# If key is the laconic address, validate that it's a valid bech32 address
if key == laconic_address:
hrp, data = bech32_decode(laconic_address)
if hrp is None or data is None or not hrp.startswith("laconic"):
print(f"Skipping invalid Laconic address: {laconic_address}")
continue
entry = {
'total_lps_allocation': row['Total LPS Allocation'] if not pd.isna(row['Total LPS Allocation']) else None,
'lock_months': row['Lock (months)'] if not pd.isna(row['Lock (months)']) else None,

View File

@ -50,7 +50,7 @@ fi
# Activate venv and install dependencies
"$venv_dir/bin/pip" install --upgrade pip
"$venv_dir/bin/pip" install requests pandas openpyxl
"$venv_dir/bin/pip" install requests pandas openpyxl bech32
echo "Running LPS lock generation script..."
"$venv_dir/bin/python" "$script_dir/generate-lps-distribution-json.py" \