
import openpyxl, json

path = '/tmp/RefSource_sync.xlsx'
wb = openpyxl.load_workbook(path, read_only=True, data_only=True)
ws = wb['AllFund']
data = {}
for row in ws.iter_rows(min_row=10, values_only=True):
    fund = row[1]
    debtor = row[5]
    amt = row[20]
    if not debtor or not fund:
        continue
    ds = str(debtor).strip()
    if ds in ("Debtor's name", '', '-'):
        continue
    k = ds.lower()
    f = str(fund).strip()
    if k not in data:
        data[k] = {}
    try:
        data[k][f] = data[k].get(f, 0.0) + float(amt or 0)
    except Exception:
        pass
wb.close()

# print all keys containing certain substrings
for term in ['ntt', 'panasonic', 'nippon', 'telephone', 'dover', 'nike', 'ge health', 'healthcare', 'intel', 'amazon', 'familymart', 'family mart']:
    matches = [k for k in data.keys() if term in k]
    print(term, '->', matches)
