I have a huge list of dates and numbers like this:
1.1.2018 0:00;2590
3.1.2018 1:00;2530
4.2.2018 2:00;1700
6.2.2018 3:00;2340
18.3.2018 4:00;1800
15.4.2018 5:00;2850
...
And I need to add all numbers together that have the same week number and return total of numbers in a week like this:
0;0
1;549730
2;645010
3;681320
4;677060
5;698450
...etc
52;576280
53;81640
This is my code so far, I've separated the dates and numbers in their own lists but not sure how to go on from here.
import datetime
def main():
file = open("2018Electricity.txt", "r")
line = file.readline()
time_list = []
electricity_list = []
total = []
for i in file:
time = i.strip().split(';')[0]
electricity = i.strip().split(';')[1]
time_list.append(datetime.strptime(time, '%d.%m.%Y %H:%M'))
electricity_list.append(electricity)
file.close()
main()
The task requires me to have weeks 0-53 and to use lists and strftime %W.