There are a few approaches that can be used to extract the street name from the street address. The one I will use here is to make a regular expression to recognize just the street number. The street number regular expression can be used to split the street address string. In the resulting array, the second entry should contain the street name.
In the following continuation of extract_street_addresses.py
, an additional regular expression is created to match just the street number and the following white space. Within the for loop that iterates over the data, the street_number_regex
regular expression is used to split the street_address
string into two components, the second of which contains the street name:
.... ### JUST THE STREET NUMBER ## match street number at the beginning of string street_number_pattern_string = "^[0-9]+" ## match space characters street_number_pattern_string += "\s+" ## compile the pattern street_address_regex = re.compile(street_address_pattern_string...