[go: up one dir, main page]

File: states.py

package info (click to toggle)
dict-gazetteer2k 1.0.0-3
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 17,704 kB
  • ctags: 65
  • sloc: python: 249; makefile: 64; sh: 25
file content (15 lines) | stat: -rw-r--r-- 359 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
from gzip import GzipFile

statedict = {}

fh = GzipFile("/usr/share/misc/postal.codes.gz", "rb")

for line in fh.readlines():
    if line[0] == '#':
        continue
    line = line.strip()
    splitline = line.split(":")
    if len(splitline) != 2:
        continue
    if not statedict.has_key(splitline[0]):
        statedict[splitline[0]] = splitline[1]