Last active
November 19, 2015 04:10
-
-
Save dracodoc/f0eeeac91eb0d68c712c to your computer and use it in GitHub Desktop.
python script to split the multiple states loader script generated by PostGIS Tiger Geocoder into separate script for each state
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
__author__ = 'draco' | |
# split all states loader script into separate scripts by states. | |
# replace all the "set TMPDIR=..." line with ":: ---- end state ----\nset TMPDIR=..." | |
# then delete the first line of ":: ---- end state ----\n" | |
# modify the base file path and output file folder by your case. | |
text_file = open("e:\\Data\\all_states.bat","r") | |
lines = text_file.readlines() | |
text_file.close() | |
print len(lines) | |
sep = ":: ---- end state ----\n" | |
file_no = 1 | |
temp = "" | |
for line in lines[0:]: | |
if line != sep: | |
temp += line | |
else: | |
state_file = open("e:\\Data\\" + str(file_no).zfill(2) + ".bat", 'w') | |
state_file.write(temp) | |
state_file.close() | |
temp = line | |
file_no += 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment