Skip to content

Instantly share code, notes, and snippets.

@dandye
Created June 18, 2012 14:48
Show Gist options
  • Save dandye/2948732 to your computer and use it in GitHub Desktop.
Save dandye/2948732 to your computer and use it in GitHub Desktop.
Search for FIPS codes and create files_list.txt files.
import os,sys
import re
counties = [x.strip() for x in open("/mnt/tiger/counties_fips_list.txt").readlines()]
for county in counties:
of = open("/mnt/tiger/TIGER2011/wg_fips/tl_2011_{}/files_list.txt".format(county),"w")
for threetuple in os.walk("/mnt/tiger/TIGER2011/"):
for filename in threetuple[-1]:
if county in os.path.join(threetuple[0],filename):
of.write(os.path.join(threetuple[0],filename)+"\n")
of.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment