Skip to content

Instantly share code, notes, and snippets.

@mgmarino
Created May 12, 2011 09:15
Show Gist options
  • Save mgmarino/968225 to your computer and use it in GitHub Desktop.
Save mgmarino/968225 to your computer and use it in GitHub Desktop.
Sort Juan events
import csv
cleaned_file = 'before_fire_LG_cleaned.txt'
all_events_file = 'LE4.txt'
output_file = 'LE5MGM.txt'
cleaned = csv.reader(open(cleaned_file), delimiter='\t')
clean_events = dict( [ (row[0], {'ts' : row[0],
'energy' : row[1],
'line' : ' '.join(row[:2]) } )
for row in cleaned] )
all_list = [row for row in csv.reader(open(all_events_file), delimiter='\t')]
all_events = [ "\t".join(row[:3] + [str(int(clean_events.has_key(row[0])))])
for row in all_list]
open(output_file, 'w').write('\n'.join(all_events) + '\n')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment