Skip to content

Instantly share code, notes, and snippets.

@mdnurahmed
Created January 8, 2021 18:58
Show Gist options
  • Save mdnurahmed/da9315bacfcea5330c6dd2c60a69b0b7 to your computer and use it in GitHub Desktop.
Save mdnurahmed/da9315bacfcea5330c6dd2c60a69b0b7 to your computer and use it in GitHub Desktop.
Reading and processing clockify csv file
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