def METHOD_NAME(filepath, headings, bs_rows):
    json_out = {}
    for row in bs_rows:
        cells = [
            cell.text.replace(",", "").strip()
            for cell in row.findAll("td")
            if row.findAll("td")
        ]
        if len(cells) == 2:
            json_out[cells[0]] = cells[1]
        else:
            tups = zip(headings[1:], cells[1:])
            tupd = {}
            for tup in tups:
                tupd[tup[0]] = tup[1]
            json_out[cells[0]] = tupd
    with open(filepath, "w") as f:
        f.write(json.dumps(json_out))