File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 55 @echo " clean-build - remove build artifacts"
66 @echo " clean-py - remove Python file artifacts"
77 @echo " clean-test - remove test and coverage artifacts"
8+ @echo " clean-data - remove all downloaded files in data/"
89
10+ make_data :
11+ mkdir data
912
1013data/cities500.txt :
1114 curl -o data/cities500.zip http://download.geonames.org/export/dump/cities500.zip
@@ -31,9 +34,9 @@ data/countryInfo.txt:
3134 curl -o data/countryInfo.txt http://download.geonames.org/export/dump/countryInfo.txt
3235
3336data/us_counties.txt :
34- curl -o data/us_counties.txt https://www2.census.gov/geo/docs/reference/codes/files/national_county .txt
37+ curl -o data/us_counties.txt https://www2.census.gov/geo/docs/reference/codes2020/national_county2020 .txt
3538
36- dl : data/cities500.txt data/cities1000.txt data/cities5000.txt data/cities15000.txt data/countryInfo.txt data/us_counties.txt
39+ dl : make_data data/cities500.txt data/cities1000.txt data/cities5000.txt data/cities15000.txt data/countryInfo.txt data/us_counties.txt
3740
3841json :
3942 ' ./bin/continents.py'
4245 ' ./bin/us_counties.py'
4346 mv data/* .json geonamescache/data/
4447
45- clean : clean-build clean-py clean-test
48+ clean : clean-build clean-py clean-test clean-data
49+
50+ clean-data :
51+ rm -fr data/
4652
4753clean-build :
4854 rm -fr build/
Original file line number Diff line number Diff line change 77
88reader = csv .reader (p_data .joinpath ('us_counties.txt' ).open ())
99
10- counties = [{'fips' : line [1 ] + line [2 ], 'name' : line [3 ], 'state' : line [0 ]} for line in reader ]
10+ state_name_idx = 0
11+ state_fips_idx = 1
12+ county_fips_idx = 2
13+ county_name_idx = 4
14+
15+ counties = []
16+ for line in reader :
17+ current_line = line [0 ].split ("|" )
18+ counties .append (
19+ {
20+ 'fips' : current_line [state_fips_idx ] + current_line [county_fips_idx ],
21+ 'name' : current_line [county_name_idx ],
22+ 'state' : current_line [state_name_idx ]
23+ }
24+ )
1125
1226p_data .joinpath ('us_counties.json' ).write_text (json .dumps (counties ))
You can’t perform that action at this time.
0 commit comments