- Timestamp:
- 2021-03-26T17:51:23+13:00 (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/model-sites-dev/eurovision-lod/collect/eurovision/prepare/errata-categories/esc-wikipedia-download-and-process-votes.py
r34976 r34977 52 52 return header_to_vals 53 53 54 def convert_cols_to_country_recs(header_to_vals,year): 55 56 country_recs = {} 57 54 def convert_cols_to_country_year_recs(header_to_vals,year): 55 56 country_year_recs = {} 57 58 a_href_re = re.compile(r"^.*" + str(year) + r"$") 59 58 60 for country_tag in header_to_vals.get("Country"): 59 61 # print("@@@@@ td = " + repr(country_tag)); 60 62 61 country = country_tag.find("a",href=re.compile(r"^.*" + str(year) + r"$")).string 63 #country = country_tag.find("a",href=re.compile(r"^.*" + str(year) + r"$")).string 64 country = country_tag.find("a",href=a_href_re).string 62 65 # print("**** country = " + country) 63 64 country_recs[country] = {} 66 country_year = country+str(year) 67 68 country_year_recs[country_year] = {} 65 69 66 70 for key in header_to_vals.keys(): … … 73 77 country_tag = header_to_vals.get("Country")[l] 74 78 country_flag_img = country_tag.find("img") 75 country = country_tag.find("a",href=re.compile(r"^.*" + str(year) + r"$")).string 79 #country = country_tag.find("a",href=re.compile(r"^.*" + str(year) + r"$")).string 80 country = country_tag.find("a",href=a_href_re).string 81 country_year = country+str(year) 76 82 77 83 val = vals[l] 78 print("@@@ val = " + repr(val))79 84 80 85 if key == "Artist": … … 106 111 #print("*** storing: " + country + "[" + key + "] = " + val) 107 112 108 country_ recs[country][key] = val109 110 return country_ recs111 112 def output_country_ recs(country_recs):113 114 for country_name in country_ recs.keys():115 country_rec = country_ recs.get(country_name)113 country_year_recs[country_year][key] = val 114 115 return country_year_recs 116 117 def output_country_year_recs(country_year_recs): 118 119 for country_name in country_year_recs.keys(): 120 country_rec = country_year_recs.get(country_name) 116 121 117 122 print("[" + country_name + "]") … … 164 169 header_to_vals = html_tablerows_to_hashmap(table_rows) 165 170 166 country_ recs = convert_cols_to_country_recs(header_to_vals,year)171 country_year_recs = convert_cols_to_country_year_recs(header_to_vals,year) 167 172 168 173 print() 169 174 print("==========") 170 175 171 output_country_ recs(country_recs)176 output_country_year_recs(country_year_recs) 172 177 173 178
Note:
See TracChangeset
for help on using the changeset viewer.