# keep stats across all points in all files. mean_lat = 0 mean_long = 0 count = 0 previous_point_1 = None previous_point_2 = None for filename in dircache.listdir(LOGFILE_DIR): if os.path.isdir(LOGFILE_DIR+filename): continue if filename[filename.rfind('.')+1:].lower() != 'txt': continue print 'now processing:', filename logfile = open(LOGFILE_DIR+filename) # returned points are cleaned for basic validity points.extend(libgps.points_from_file(logfile, 'NMEA', 'date', 'time')) if not points: continue for point in points: count += 1 mean = ((mean.lat + point.lat), (mean.long+point.long)/count out.flush() out.close()
@ATTRIBUTE datetime date "yyyy-MM-dd'T'HH:mm:ss" @data ''' for filename in dircache.listdir(LOGFILE_DIR): if os.path.isdir(LOGFILE_DIR+filename): continue if filename[filename.rfind('.')+1:].lower() != 'txt': continue print 'now processing:', filename logfile = open(LOGFILE_DIR+filename) # returned points are cleaned for basic validity points = libgps.points_from_file(logfile, 'NMEA', 'date', 'time') if not points: #out.close() #os.remove(outfile) continue for point in points: print >> out, '%s,%s,"%s"' % (point.long, point.lat, point.datetime.isoformat()) out.flush() out.close()