import csv
with open('BPMFMappings.txt', 'r', encoding='utf-8') as f:
lines = f.readlines()
BPMFMappings = set()
for line in lines:
BPMFMappings.add(line.split()[0])
with open('town.csv', 'r', encoding='utf-8-sig', newline='') as f:
lines = csv.DictReader(f)
towns = set()
for line in lines:
town = line['town']
# skip empty field
if not town:
continue
towns.add(town)
# remove 鎮、鄉、市、區
pure = town[:-1]
# exclude single character like 中(區)
if len(pure) > 1:
towns.add(pure)
diff = sorted(towns.difference(BPMFMappings))
print('\n'.join(diff))
This PR is a follow-up to https://github.com/openvanilla/McBopomofo/pull/500, adding the missing administrative regions of Taiwan to the list.
The data was sourced from 政府資料開放平臺 under the dataset 地名資料行政區域類.