if data.cell(row,13).value: po_zip_code = " ".join(data.cell(row,13).value.split()) else: po_zip_code = " ".join(data.cell(row,12).value.split()) else: po_city = " ".join(data.cell(row,10).value.split()) po_state = " ".join(data.cell(row,11).value.split()) po_zip_code = " ".join(data.cell(row,12).value.split()) phone = dogcatcher.clean_phone(" ".join(data.cell(row,5).value.split())) fax = dogcatcher.clean_phone(" ".join(data.cell(row,6).value.split())) email = " ".join(data.cell(row,7).value.lower().split()) website = dogcatcher.clean_website(data.cell(row,14).value.rstrip().replace("//","+++++")) fips = dogcatcher.find_fips(county_name, voter_state) result.append([authority_name, first_name, last_name, county_name, fips, street, city, address_state, zip_code, po_street, po_city, po_state, po_zip_code, reg_authority_name, reg_first, reg_last, reg_street, reg_city, reg_state, reg_zip_code, reg_po_street, reg_po_city, reg_po_state, reg_po_zip_code, reg_phone, reg_fax, reg_email, reg_website, reg_hours, phone, fax, email, website, hours, voter_state, source, review]) #This outputs the results to a separate text file. dogcatcher.output(result, voter_state, cdir)
phone = "(603)" + town_item[3] if town_item[4] != " ": fax = "(603)" + town_item[4] else: fax = "" if fax == "(603)155-9128": fax = "(603)755-9128" email = town_item[5].lower() if website == "none available" or website == " ": website = "" else: website = dogcatcher.clean_website(town_item[6]) #The full address is its own item, and there's either a PO Box or nothing. This block of code: #1. Checks for a PO Box. If so, extracts it. It then checks for a city and zip code the same way. If there's no zip code, it grabs it form the polling place indicated in later column. #2. If no PO Box, it extracts a street address (details described earlier), and then a zip code and city. address = town_item[2] if "O BOX" in address: try: po_street = po_re.findall(address)[0].strip() except: po_street = po_2_re.findall(address)[0].strip() try: po_city = po_city_re.findall(address)[0].strip() except: po_city = town_name
phone = "(603)" + town_item[3] if town_item[4] != " ": fax = "(603)" + town_item[4] else: fax = "" if fax == "(603)155-9128": fax = "(603)755-9128" email = town_item[5].lower() if website == "none available" or website == " ": website = "" else: website = dogcatcher.clean_website(town_item[6]) # The full address is its own item, and there's either a PO Box or nothing. This block of code: # 1. Checks for a PO Box. If so, extracts it. It then checks for a city and zip code the same way. If there's no zip code, it grabs it form the polling place indicated in later column. # 2. If no PO Box, it extracts a street address (details described earlier), and then a zip code and city. address = town_item[2] if "O BOX" in address: try: po_street = po_re.findall(address)[0].strip() except: po_street = po_2_re.findall(address)[0].strip() try: po_city = po_city_re.findall(address)[0].strip() except: po_city = town_name
if data.cell(row, 13).value: po_zip_code = " ".join(data.cell(row, 13).value.split()) else: po_zip_code = " ".join(data.cell(row, 12).value.split()) else: po_city = " ".join(data.cell(row, 10).value.split()) po_state = " ".join(data.cell(row, 11).value.split()) po_zip_code = " ".join(data.cell(row, 12).value.split()) phone = dogcatcher.clean_phone(" ".join(data.cell(row, 5).value.split())) fax = dogcatcher.clean_phone(" ".join(data.cell(row, 6).value.split())) email = " ".join(data.cell(row, 7).value.lower().split()) website = dogcatcher.clean_website( data.cell(row, 14).value.rstrip().replace("//", "+++++")) fips = dogcatcher.find_fips(county_name, voter_state) result.append([ authority_name, first_name, last_name, county_name, fips, street, city, address_state, zip_code, po_street, po_city, po_state, po_zip_code, reg_authority_name, reg_first, reg_last, reg_street, reg_city, reg_state, reg_zip_code, reg_po_street, reg_po_city, reg_po_state, reg_po_zip_code, reg_phone, reg_fax, reg_email, reg_website, reg_hours, phone, fax, email, website, hours, voter_state, source, review ]) #This outputs the results to a separate text file. dogcatcher.output(result, voter_state, cdir)