Example #1
0
data = data.replace("&", "&")

#This splits the complete data into a list containing one item/county.

county_data = county_data_re.findall(data)

for county in county_data:

    authority_name, first_name, last_name, county_name, town_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, review = dogcatcher.begin(
        voter_state)

    county_name = county_name_re.findall(county)[0]

    county_data_item = county_data_item_re.findall(county)

    first_name, last_name, authority_name, review = dogcatcher.make_name(
        county_data_item[0], ", ", review)

    print county_data_item[0]

    #print authority_name + " | " + first_name + " " + last_name

    #This section generates the address. It does so by identifying whether there are one or two address-looking things in the data. (CA explicitly prints a separate mailing address when counties have them.)
    #CA addresses are formatted "Street\nCity, State, Zip"
    #If there is one, it is the mailing and registration address; if there are two, the second is the mailing address, and the first is the address.
    #After finding these, it applies the same procedure to both: it identifies a city/state/zip (csz) combination and removes that from the full address, leaving behind a street address with some garbage.
    #It then cleans up the street address and pulls the city, state, and zip out of the csz.

    address_full = address_re.findall(county)
    address = address_full[0]
    if len(address_full) > 1:
        mailing_address = address_full[1]
Example #2
0
    #fixing an edge case in Baltimore City
    if county_name == "Baltimore City":
        if "for Absentee Ballots Only" and "410-727-1775" in county:
            reg_fax = fax
            fax = "410-727-1775"
        else:
            print "Something's changed in Baltimore City."
            sys.exit()

    print "_______________________________________"
    print county
    print "======================================="

    official_name = official_name_re.findall(county)[0].lstrip("\n ")
    first_name, last_name, authority_name, review = dogcatcher.make_name(
        official_name, ",", review)

    #This section generates the address. In Maryland, there's either a single street address, or explicitly delineated street and mailing addresses.
    #This checks whether the latter case is true. If so, it isolates both addresses and creates a street address, city, state, and zip separately.
    #If not, it creates only a street address.

    street_address_check = street_address_re.findall(county)

    if street_address_check:
        street_address = street_address_check[0]

        street_csz = csz_re.findall(street_address)[0]
        city = city_re.findall(street_csz)[0]
        address_state = state_re.findall(street_csz)[0]
        zip_code = zip_re.findall(street_csz)[0]
        street = street_address.replace(street_csz,
Example #3
0
data = data.replace("&","&")

#This splits the complete data into a list containing one item/county.

county_data = county_data_re.findall(data)

for county in county_data:

  authority_name, first_name, last_name, county_name, town_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, review = dogcatcher.begin(voter_state)

  county_name = county_name_re.findall(county)[0]

  county_data_item = county_data_item_re.findall(county)

  first_name, last_name, authority_name, review = dogcatcher.make_name(county_data_item[0], ", ", review)

  print county_data_item[0]

  #print authority_name + " | " + first_name + " " + last_name


  #This section generates the address. It does so by identifying whether there are one or two address-looking things in the data. (CA explicitly prints a separate mailing address when counties have them.)
  #CA addresses are formatted "Street\nCity, State, Zip"
  #If there is one, it is the mailing and registration address; if there are two, the second is the mailing address, and the first is the address.
  #After finding these, it applies the same procedure to both: it identifies a city/state/zip (csz) combination and removes that from the full address, leaving behind a street address with some garbage.
  #It then cleans up the street address and pulls the city, state, and zip out of the csz.

  address_full = address_re.findall(county)
  address = address_full[0]
  if len(address_full)>1:
Example #4
0
    state_re = re.compile(" ([A-Z][A-Z]) ")
    zip_re = re.compile(" (\d{5}[\d-]*)")
    po_re = re.compile("(P[oO] Box .+) *", re.DOTALL)
    email_re = re.compile("Email: (.+?) *<")

    municipal_re = re.compile("href=\"LocalClerk\.aspx\?jd=(\d{5})")
    municipality_list.extend(municipal_re.findall(data))

    authority_name, first_name, last_name, county_name, town_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, review = dogcatcher.begin(
        voter_state)

    county_name = county_name_re.findall(county)[0]

    official = official_name_re.findall(county)[0]

    first_name, last_name, official_name, review = dogcatcher.make_name(
        official, ",", review)

    email = dogcatcher.find_emails(email_re, county)
    phone = dogcatcher.find_phone(phone_re, county)
    fax = dogcatcher.find_phone(fax_re, county)

    #This section finds the address. After finding the address, it identifies a city/state/zip (csz) combination and a PO Box number if that exists.
    #It removes both the CSZ and the PO Address (if it exists) from the full address, leaving behind a street address with some garbage.
    #It then cleans up the street address and pulls the city, state, and zip out of the csz, and assigns them as appropriate to the street address and state.

    address = address_re.findall(county)[0].replace(
        "</span><br><span ID=\"lblAddress2\" Class=\"clerkText\">", "")

    csz = csz_re.findall(county)[0]

    try:
Example #5
0
	if county_name == "Baltimore City":
		if "for Absentee Ballots Only" and "410-727-1775" in county:
			reg_fax = fax
			fax = "410-727-1775"
		else:
			print "Something's changed in Baltimore City."
			sys.exit()


	print "_______________________________________"
	print county
	print "======================================="


	official_name = official_name_re.findall(county)[0].lstrip("\n ")
	first_name, last_name, authority_name, review = dogcatcher.make_name(official_name, ",", review)

	#This section generates the address. In Maryland, there's either a single street address, or explicitly delineated street and mailing addresses.
	#This checks whether the latter case is true. If so, it isolates both addresses and creates a street address, city, state, and zip separately.
	#If not, it creates only a street address.

	street_address_check = street_address_re.findall(county)

	if street_address_check:
		street_address = street_address_check[0]

		street_csz = csz_re.findall(street_address)[0]
		city = city_re.findall(street_csz)[0]
		address_state = state_re.findall(street_csz)[0]
		zip_code = zip_re.findall(street_csz)[0]
		street = street_address.replace(street_csz,"").replace("\r\n",", ").replace("<br />","").strip(", ")
Example #6
0
po_re = re.compile("P\.*O\.* .+")

name_line_re = re.compile("\d\s*<br />\s+([^\d]+)</td")

authority_name_re = re.compile(",\s+([^\d]+?)</td>")
space_re = re.compile("\s\s+")

#This splits the complete dataset into a series of towns so we can extract data form them one-by-one.

town_data = town_data_re.findall(data)

for town in town_data:
	authority_name, first_name, last_name, county_name, town_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, review = dogcatcher.begin(voter_state)

	name_line = name_line_re.findall(town)[0].replace("<br />","")
	first_name, last_name, authority_name, review = dogcatcher.make_name(name_line, ",", review)

	#Some of the authority names break in mid-line; this cleans them.

	for item in space_re.findall(authority_name):
		authority_name = authority_name.replace(item," ")

	town_name = town_name_re.findall(town)[0]


	hours = hours_re.findall(town)[0]
	hours = " ".join(hours.replace("\r\n","").replace("<br />"," ").split())

	email = dogcatcher.find_emails(email_re, town)

	phone = dogcatcher.find_phone(phone_re, town)
Example #7
0
	city_re = re.compile("(.+?) [A-Z][A-Z]")
	state_re = re.compile(" ([A-Z][A-Z]) ")
	zip_re = re.compile(" (\d{5}[\d-]*)")
	po_re = re.compile("(P[oO] Box .+) *", re.DOTALL)
	email_re = re.compile("Email: (.+?) *<")

	municipal_re = re.compile("href=\"LocalClerk\.aspx\?jd=(\d{5})")
	municipality_list.extend(municipal_re.findall(data))

	authority_name, first_name, last_name, county_name, town_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, review = dogcatcher.begin(voter_state)

	county_name = county_name_re.findall(county)[0]

	official = official_name_re.findall(county)[0]

	first_name, last_name, official_name, review = dogcatcher.make_name(official, ",", review)

	email = dogcatcher.find_emails(email_re, county)
	phone = dogcatcher.find_phone(phone_re, county)
	fax = dogcatcher.find_phone(fax_re, county)

	#This section finds the address. After finding the address, it identifies a city/state/zip (csz) combination and a PO Box number if that exists.
    #It removes both the CSZ and the PO Address (if it exists) from the full address, leaving behind a street address with some garbage.
    #It then cleans up the street address and pulls the city, state, and zip out of the csz, and assigns them as appropriate to the street address and state.

	address = address_re.findall(county)[0].replace("</span><br><span ID=\"lblAddress2\" Class=\"clerkText\">","")

	csz = csz_re.findall(county)[0]

	try:
		po_street = po_re.findall(address)[0].replace(csz,"").strip(", ")