Created
August 6, 2012 21:25
-
-
Save aaronlidman/3278567 to your computer and use it in GitHub Desktop.
simplegeo geojson Features to FeatureCollection from http://gis.stackexchange.com/a/16255
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
import sys | |
infile = sys.argv[1] | |
outfile = sys.argv[2] | |
## Prepare the input/output for read/write of files | |
fin = open(infile, 'r') | |
fout = open(outfile, 'w') | |
##Prepend the new file with approriate header info | |
fout.write('{"type":"FeatureCollection","features":[' + '\n') | |
## Read each line from the input and write to the output | |
for line in fin: | |
##write each line in the table, and replace carriage returns with "," + carriage return | |
fout.write(line.replace("\n",",\n")) | |
##Append the new file with approriate footer info | |
fout.write(']}') | |
##Close the input and output files to release file locking | |
fin.close() | |
fout.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment