Skip to content

Instantly share code, notes, and snippets.

@higs4281
Created March 16, 2012 21:22
Show Gist options
  • Save higs4281/2052811 to your computer and use it in GitHub Desktop.
Save higs4281/2052811 to your computer and use it in GitHub Desktop.
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