import sys, os, re DATA = open('METARs.txt').readlines() out = open('labels.txt','w') SITES = [] locs = open('SITES.txt').readlines() for SITE in locs: if SITE[0] == 'K': SITES.append(SITE[0:4]) for line in DATA: line = re.split('\|',line) if line[0] in SITES: outLine = " map.addOverlay(new GMarker(new GLatLng(%s, %s)));\n" % (line[4].strip(),line[5].strip()) out.write(outLine) out.close()