Skip to main content

query zip codes and location data

Project description

Introduction

This package will allow you to get zip code information. The data used in this package is retrieved from http://pablotron.org/files/zipcodes-csv-10-Aug-2004.zip

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

Here is some basic usage..

>>> from pyzipcode import ZipCodeDatabase
>>> zcdb = ZipCodeDatabase()
>>> zipcode = zcdb[54115]
>>> zipcode.zip
u'54115'
>>> zipcode.city
u'De Pere'
>>> zipcode.state
u'WI'
>>> zipcode.longitude
-88.078959999999995
>>> zipcode.latitude
44.42042
>>> zipcode.timezone
-6

Search zip codes…

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

Get a list of zipcodes around a radius of a zipcode

>>> 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']

ChangeLog

2.0.2 (2021-02-28)

  • license update

2.0.1 (2021-02-25)

  • Fix error message for unknown zip code[mpcusack]

2.0.0 (2020-04-07)

  • updated to work with py3 [David Schneider]

1.0 (2016-01-20)

  • Fix import code so that it is not run when the module is imported (for example, when building Sphinx API Documentation).

  • Rename the import.py module to import_zipcode.py because import is a reserved Python keyword.

  • Document the import_zipcode module.

0.4

0.3

  • use strings instead of integer for storing zip codes since zip codes can start with a Zero.

0.2

  • catch sqlite db file reading errors and keep trying in case another process is trying to access the file at the same time.

0.1

  • initial release

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyzipcode-2.0.2.tar.gz (1.9 MB view details)

Uploaded Source

File details

Details for the file pyzipcode-2.0.2.tar.gz.

File metadata

  • Download URL: pyzipcode-2.0.2.tar.gz
  • Upload date:
  • Size: 1.9 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.8.5

File hashes

Hashes for pyzipcode-2.0.2.tar.gz
Algorithm Hash digest
SHA256 664eb1c876e2ed2d4f4980ff34ef727728766583405c1ee5962f0230a70f1470
MD5 2bcfa6991710de908971ec937c7565ef
BLAKE2b-256 45f06dcf4148444b5d782a578e8905f40ddbb99dde56c56c06c575596e066fed

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page