Changeset 34952
- Timestamp:
- 2021-03-01T23:47:30+13:00 (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/model-sites-dev/eurovision-lod/collect/eurovision/prepare/voting-excel/xlsx-tocountry-jsonmetadata.py
r34919 r34952 12 12 13 13 import util 14 import csvutil 14 15 import xlsxutil 15 16 … … 67 68 68 69 69 def fileset_voting_for_esc_country_in_year(to_country_year_votes ):70 def fileset_voting_for_esc_country_in_year(to_country_year_votes,countrylabel_to_uri_mapping): 70 71 71 72 # Looking to build data-structure (for output as JSON) in the form … … 104 105 tl_to_country_id = re.sub(r'\s+', '', tl_to_country) + str(tl_year) 105 106 106 metadata_array.append({ "name": "Final","content": tl_final }) 107 107 metadata_array.append({ "name": "Country","content": tl_to_country }) 108 metadata_array.append({ "name": "Year", "content": tl_year }) 109 metadata_array.append({ "name": "Final", "content": tl_final }) 110 111 # tl_to_country_lc = tl_to_country.lower() 112 tl_to_country_uri = countrylabel_to_uri_mapping.get(tl_to_country) 113 if (tl_to_country_uri != None): 114 metadata_array.append({ "name": "CountryDBURI","content": tl_to_country_uri }) 115 else: 116 util.eprint("Warning: Failed to find DBpedia Country URI match for: " + tl_to_country) 117 108 118 for to_country_year_vote in to_country_year_votes: 109 119 to_country = to_country_year_vote.get('To country') … … 150 160 151 161 152 def gs_directory_metadata(to_country_year_voting_groups ):162 def gs_directory_metadata(to_country_year_voting_groups,countrylabel_to_uri_mapping): 153 163 # Next step is to express the grouped to-country voting data 154 164 # in the Greenstone JSON metadata format: … … 178 188 for to_country_year_votes in to_country_year_voting_groups: 179 189 180 fileset = fileset_voting_for_esc_country_in_year(to_country_year_votes )190 fileset = fileset_voting_for_esc_country_in_year(to_country_year_votes,countrylabel_to_uri_mapping) 181 191 directory_metadata.append(fileset) 182 192 … … 229 239 if (json_output_filename == None): 230 240 json_output_filename = os.path.splitext(excel_input_filename)[0]+'.json' 231 241 242 countrylabel_to_uri_mapping = csvutil.load_and_tidy_csv("dbpedia--european-countries.csv") 243 232 244 worksheet = xlsxutil.load_xslx_sheet(excel_input_filename,sheetname) 233 245 … … 261 273 print() 262 274 print("Generating Greenstone JSON to-country voting metadata received by:") 263 greenstone_metadata_json = gs_directory_metadata(to_country_year_voting_groups )275 greenstone_metadata_json = gs_directory_metadata(to_country_year_voting_groups,countrylabel_to_uri_mapping) 264 276 265 277 print("Saving output as: " + json_output_filename)
Note:
See TracChangeset
for help on using the changeset viewer.