Skip to content

dvf/pyzipcode3

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code
This branch is 12 commits ahead of invernizzi:master.

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
Jun 16, 2017
Jun 2, 2017
Apr 4, 2018

pyzipcode3

This package will allow you to get zip code information using the Maxmind Cities DB. Initially a fork of https://bitbucket.org/vangheem/pyzipcode but has been updated to support Python 3.

pyzipcode uses a local sqlite database. You can replace it with your own other storage mechanism with a little effort.

Installation

pip install pyzipcode3

Usage

Simple Lookup

>>> from pyzipcode import ZipCodeDatabase
>>> zcdb = ZipCodeDatabase()
>>> zipcode = zcdb[10013]
>>> zipcode.zip
u'10013'
>>> zipcode.place
u'New York'
>>> zipcode.state
u'NY'
>>> zipcode.longitude
-74.00526
>>> zipcode.latitude
40.720666
>>> zipcode.timezone
-5

Search for ZIPs

>>> from pyzipcode import ZipCodeDatabase
>>> zcdb = ZipCodeDatabase()
>>> len(zcdb.find_zip(place="Oshkosh"))
7

Get ZIPs around a given ZIP

>>> from pyzipcode import ZipCodeDatabase
>>> zcdb = ZipCodeDatabase()
>>> [z.zip for z in zcdb.get_zipcodes_around_radius('54901', 10)]
[u'54901', u'54902', u'54903', u'54904', u'54906', u'54927', u'54952', u'54956', u'54957', u'54979', u'54985']

About

Initially a fork of https://bitbucket.org/vangheem/pyzipcode but updated to support Python 3

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 100.0%