Skip to content

Fail to find a zipcode give a city and state #68

Description

@huangming6220

Describe the problem

Plymouth Minnesota
Traceback (most recent call last):
File "C:\Users\m184194\Documents\Mayo\Projects\Patten_Facebook\scripts\facebook-friends-map\test.py", line 14, in
get_zipcode(current_city)
File "C:\Users\m184194\Documents\Mayo\Projects\Patten_Facebook\scripts\facebook-friends-map\test.py", line 9, in get_zipcode
zipcodes = engine.by_city_and_state(city=city, state=state)
File "C:\Users\m184194\Anaconda3\envs\social_media\lib\site-packages\uszipcode\search.py", line 802, in by_city_and_state
return self.query(
File "C:\Users\m184194\Anaconda3\envs\social_media\lib\site-packages\uszipcode\search.py", line 536, in query
city = self.find_city(city, state, best_match=True)[0]
File "C:\Users\m184194\Anaconda3\envs\social_media\lib\site-packages\uszipcode\search.py", line 379, in find_city
raise ValueError("'%s' is not a valid city name" % city)
ValueError: 'Ely' is not a valid city name
Exception ignored in: <function SearchEngine.del at 0x0000025E482668C0>
Traceback (most recent call last):

Sample code to reproduce the problem

from uszipcode import SearchEngine
engine = SearchEngine()

def get_zipcode(current_city):
city = current_city.split(",")[0].strip()
state = current_city.split(",")[1].strip()
print(city, state)
zipcodes = engine.by_city_and_state(city=city, state=state)
for zipcode in zipcodes:
print(zipcode.zipcode, zipcode.major_city, zipcode.population)

current_city = "Plymouth, Minnesota"
get_zipcode(current_city)
engine.close()

Potential Solution

Maybe you can try talk to the author lively here https://gitter.im/MacHu-GWU-Python-Library-Technical-Support/community

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions