Last active
December 20, 2016 20:43
-
-
Save nickserv/e12b49d2eb937d462ec231d3b8467fa3 to your computer and use it in GitHub Desktop.
Simple Python 3 script to sum a list of durations. Data from https://soundcloud.com/wmstrecs/sets/n-o-i-s-e.
This file contains 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
4:24 | |
1:58 | |
4:47 | |
3:44 | |
3:55 | |
1:53 | |
6:49 | |
4:04 | |
12:01 | |
3:24 | |
5:10 | |
4:03 | |
16:55 | |
7:38 | |
3:37 | |
18:44 |
This file contains 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
from datetime import timedelta | |
from functools import reduce | |
from operator import add | |
def parse_duration(duration_string): | |
sections = map(int, duration_string.split(':')) | |
return timedelta(minutes=next(sections), seconds=next(sections)) | |
with open("durations.txt") as f: | |
duration_strings = f.readlines() | |
print(reduce(add, map(parse_duration, duration_strings))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment