Created
March 25, 2011 02:09
-
-
Save neilkod/886238 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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