From ddf8f22fe8b8817a73ebf3af006c82138b46b322 Mon Sep 17 00:00:00 2001 From: Jeremy Stanley Date: Thu, 13 Feb 2014 00:48:25 +0000 Subject: [PATCH] Correlation building fixes * weather.py(correlate): Note the updated URL to Census Bureau data in file comments, and make the County-Public Forecast Zones Correlation File parsing more robust against errors in the file formatting. --- weather.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/weather.py b/weather.py index cd22db3..2bacc27 100644 --- a/weather.py +++ b/weather.py @@ -1,7 +1,7 @@ """Contains various object definitions needed by the weather utility.""" weather_copyright = """\ -# Copyright (c) 2006-2012 Jeremy Stanley . Permission to +# Copyright (c) 2006-2014 Jeremy Stanley . Permission to # use, copy, modify, and distribute this software is granted under terms # provided in the LICENSE file distributed with this software. #""" @@ -1226,7 +1226,7 @@ def correlate(): %s # generated by %s on %s from these public domain sources: # -# http://www.census.gov/geo/www/gazetteer/gazetteer2010.html +# http://www.census.gov/geo/maps-data/data/gazetteer2010.html # %s %s %s # %s %s %s # %s %s %s @@ -1545,12 +1545,12 @@ def correlate(): cpfz = {} cpfzcf = open(cpfzcf_fn) for line in cpfzcf: - fields = line.split("|") + fields = line.strip().split("|") if len(fields) == 11 \ and fields[0] and fields[1] and fields[9] and fields[10]: zone = "z".join( fields[:2] ).lower() if zone in zones: - zones[zone]["centroid"] = gecos( ",".join( fields[9:] ) ) + zones[zone]["centroid"] = gecos( ",".join( fields[9:11] ) ) elif fields[6]: state = fields[0] description = fields[3] -- 2.11.0