def load_hud_crosswalk(fn):
book = xlrd.open_workbook(fn)
sheet = book.sheet_by_index(0)
zccd = []
for row_i in xrange(1, sheet.nrows):
z = sheet.cell(row_i, 0).value
stcd = sheet.cell(row_i, 1).value # formatted like STCD (FIPS, CD)
st = stcd[:2]
cd = stcd[2:]
try:
zccd.append({
'zip': z,
'state_fips': st,
'state_abbr': FIPS_TO_STATE[st],
'cd': str(int(cd)) # string conversion to drop leading zero
})
except Exception,e:
msg = 'unable to convert CD for %s: %s' % (z, stcd)
log.error(msg)
continue
return zccd
hud_crosswalk.py 文件源码
python
阅读 18
收藏 0
点赞 0
评论 0
评论列表
文章目录