Hello,
Basically currently my program reads the Data file (electric info), sums the values up, and after summing the values, it changes all the negative numbers to 0, and keeps the positive numbers as they are. The program does this perfectly. This is the code I currently have:
import csv
from datetime import timedelta
from collections import defaultdict
def convert(item):
try:
return float(item)
except ValueError:
return 0
sums = defaultdict(list)
def daily():
lista = []
with open('Data.csv', 'r') as inp:
reader = csv.reader(inp, delimiter = ';')
headers = next(reader)
for line in reader:
mittaus = max(0,sum([convert(i) for i in line[1:-2]]))
lista.append()
daily()
My question is: How can I save the data to lists, so I can add all the values per day, so should look something like this
1.1.2016;358006
2.1.2016;39
3.1.2016;0 ...
8.1.2016;239143
And After had having these in a list (to save later on to a new data file), it should calculate the cumulative values, which would look like this:
1.1.2016;358006
2.1.2016;358045
3.1.2016;358045...
8.1.2016;597188
These should be in a new subprogram
Small peak what's behind the Data file: https://pastebin.com/9HxwcixZ [It's actually divided with ';' , not with ' ' as in the pastebin]
The data file: https://files.fm/u/yuf4bbuk
What I have tried:
def analysointi():
lista = []
reader = csv.reader(inp, delimiter = ';')
for line in reader:
lista.append(line)
print(line[2])
analysointi()
Thinking about this way, it shouldn't work, as the values should already be in a list, so this way can be dumped.
I have tried to search for results, asked people, but I haven't got any solution. I just can't solve it myself, so I'd appreciate it so much if someone could help me