I have a dictData dictionary that was created from 3 columns (0, 3 and 4) of the csv file, where each key is a datetime object, and each value is a list containing two numbers (let them name b, so the list is [a , b]) is saved as strings:
import csv import datetime as dt with open(fileInput,'r') as inFile: csv_in = csv.reader(inFile) dictData = {(dt.datetime.strptime(rows[0],'%d/%m/%Y %H:%M')):[rows[3],rows[4]] for rows in csv_in}
I want to do two things: firstly, I want to summarize each of the values ββin the list (i.e., sum all the values ββof a, and then sum all the values ββof b) for the entire dictionary. If it were a dictionary with single values, I would do something like this:
total = sum((float(x) for x in dictData.values()))
source share