Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
huangming6220 opened this issue Oct 26, 2022 · 1 comment
Open

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

huangming6220 opened this issue Oct 26, 2022 · 1 comment

Comments

@huangming6220
Copy link

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

@jonathangreen
Copy link

@huangming6220 i believe this PR will probably fix your issue:

#73

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

No branches or pull requests

2 participants