def parse_freq_html(file_path): with file(file_path) as f: html = f.read() f.close() soup = BeautifulSoup(html) kanji_table = soup.find('table') for row in kanji_table.findAll('tr'): cols = row.findAll('td') if cols: Kanji( rank=cols[0].string, character=cols[1].a.string, frequency=cols[2].string, dominance=cols[3].string[:-1], picked=0) update_db()