# * Longitude # # The first line of the file is a header and should be discarded. # The fields are seperated by commas and quoted with double quotes. f = urlopen(CSV_URL) count = 0 data = csv.reader(f, delimiter=',', quotechar='"') for row in data: count += 1 if count == 1: continue repeater = Repeater(row[0]) repeater.tx = float(row[3]) repeater.rx = float(row[4]) if row[10] != '': repeater.ctcss = float(row[10]) if row[5] == "AV": repeater.mode = "FM" if row[5] == "DSTAR": repeater.mode = "DSTAR" if row[5] == "DMR": repeater.mode = "DMR" if row[5] == "DUALMODE": repeater.mode = "FM" repeater.locator = row[6] repeater.town = row[7] repeater.keeper = row[11] repeater.lat = row[12]
geolocator = Nominatim() repeater_rows = irts_soup.find_all('table')[0].find_all('tr') count = 0 for row in repeater_rows: count = count + 1 if count == 1: continue # Skip the header row fields = row.find_all('td') repeater = Repeater(fields[2].next_element.strip()) if repeater.callsign[0:2] == "GB": continue # we get these anyway from ukrepeater repeater.rx = fields[1].next_element.next_element.next_element.strip() repeater.tx = fields[1].next_element.next_element.next_element.next_element.next_element.next_element.next_element.strip() activation = re.sub("\/", "", fields[3].next_element.strip()) if activation == "Carrier": repeater.carrier = True elif activation == "1750Hz": repeater.burst = True else: repeater.ctcss = re.sub("Hz", "", activation) repeater.mode = "FM" repeater.town = fields[4].next_element.strip() location = geolocator.geocode(re.sub(",.*$", "", repeater.town) + ", Republic of Ireland", timeout=10) if location == None: continue # TODO need to get a better geocoding system, or actually pull out the ml repeater.lat = location.latitude repeater.lon = location.longitude repeater.locator = latlong_to_locator(repeater.lat, repeater.lon)
return '\n'.join(unique_repeaters) # Assuming these four locations will result in a complete set data = assemble_repeater_data(["JO41AD", "JO53BJ", "JO62FD", "JN59EH"]) # Clean it up a bit data = data.replace('\r', '') data = data.replace('°', ' ') for row in csv.reader(data.split('\n'), delimiter=';'): if len(row) != 9: continue repeater = Repeater(row[0]) try: repeater.tx = float(row[1].replace(',', '.')) except ValueError: # Some data is just wrong or malformatted pass if (row[2] != '') and (row[2] != 'Beacon'): try: repeater.rx = float(row[2].replace(',', '.')) except ValueError: pass if row[8] == 'DMR': # Unfortunately, most will be missing this repeater.mode = row[8] if row[7] != '': repeater.ctcss = float(row[7].replace(',', '.')) repeater.mode = "FM" repeater.locator = row[3] # The fourth column is actually info, and *usually* has the town name.