Created
January 8, 2021 18:58
-
-
Save mdnurahmed/da9315bacfcea5330c6dd2c60a69b0b7 to your computer and use it in GitHub Desktop.
Reading and processing clockify csv file
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
import csv | |
from collections import defaultdict | |
def duration_to_seconds(duration): | |
elements = duration.split(':') | |
hour = int(elements[0]) | |
min = int(elements[1]) | |
sec = int(elements[2]) | |
return hour*60*60 + min*60 + sec | |
mydict = defaultdict(int) | |
with open('clockify.csv', 'r') as file: | |
reader = csv.reader(file) | |
line = 0 | |
for row in reader: | |
line += 1 | |
# we are skipping the first line as it just contains title of the colums | |
if line > 1 : | |
date = row[8] | |
duration = row[12] | |
mydict[date] += duration_to_seconds(duration) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment