Created
March 16, 2012 21:22
-
-
Save higs4281/2052811 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 re | |
def kml_fixer(DIRECTORY, FILENAME): | |
file_in=DIRECTORY+'/'+FILENAME | |
file_out=DIRECTORY+'/NEW_'+FILENAME | |
with open(file_in, "r+") as f: | |
old = f.read() | |
x = re.findall(r'<Point>\n.*\n.*<\/Point>', old) | |
for each in x: | |
old = old.replace(each, "") | |
with open(file_out, "w") as neww: | |
neww.write(old) | |
""" | |
REGEXES | |
FOR KML'S WITH NAME INSIDE THE POINT FIELD: | |
x = re.findall(r'<Point>\n.*\n.*\n.*<\/Point>', old) | |
FOR KML'S WITH A BARE POINT FIELD: | |
x = re.findall(r'<Point>\n.*\n.*<\/Point>', old) | |
"""" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment