def load_zipcodes(): headers = ( 'country_code','postal_code','name', 'state_name','state_code', 'county_name','county_code', 'community_name','community_code', 'latitude','longitude','accuracy' ) state_histogram = Histogram('state_code') state_histogram.label_length = 2 csv_path = settings.dataset_path('default', filename='zipcodes.txt') run_recipe( CSVSource(open(csv_path), delimiter="\t", fieldnames=headers), FieldKeeper(('postal_code','name','state_code','latitude','longitude')), FieldModifier(('latitude','longitude'), float), FieldMerger({'latlng': ('latitude', 'longitude')}, lambda lat, lng: (lat, lng)), #MongoZipEmitter(), #DebugEmitter(), state_histogram, ) return str(state_histogram)
def test_histogram(self): fltr = Histogram('a') fltr.label_length = 1 list(fltr.attach(self._simple_data())) self.assertEqual(str(fltr), "\n1 **\n5 *\n")