Skip to content

Instantly share code, notes, and snippets.

@neilkod
Created March 25, 2011 02:09
Show Gist options
  • Save neilkod/886238 to your computer and use it in GitHub Desktop.
Save neilkod/886238 to your computer and use it in GitHub Desktop.
#!/bin/python
f=open('5k.txt')
# column headers
print ','.join(['runner_name','seconds','team','minutes'])
for line in f:
data = line.strip()
(bib,name,time,gender,team) = data.split('\t')
# split the time on :. If it has 2 components then it's MM:SS.
# if 3 components then HH:MM:SS
time_components = time.split(':')
if len(time_components) == 2:
secs = (int(time_components[0]) * 60) + int(time_components[1])
elif len(time_components) == 3:
secs = (int(time_components[0]) * 3600) + (int(time_components[1]) * 60) + int(time_components[2])
print "%s\t%s\t%s\t%.2f" % (name.lower(),secs,team,float(secs)/60)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment