You could do this pandas quite easily
import pandas as pd
# read in the csv
# group by the date column, and sum the other columns
# reset index to get the dates as a series
# convert dataframe to dictionary
out = pd.read_csv('file.csv').groupby('date').sum().reset_index().to_dict('records')
#Out I
[{'date': '26-03-2020', 'marks': 2796, 'course1': 2157},
{'date': '27-03-2020', 'marks': 2212, 'course1': 1783}]
# Out II
# if you insist on having it as a dict of dicts
out = {k['date']: {'marks': k['marks'], 'course1': k['course1']} for k in out }
{
'26-03-2020': {'marks': 2796, 'course1': 2157},
'27-03-2020': {'marks': 2212, 'course1': 1783}
}
Further explanation for clarity
It is not possible to have a dictionary the way that you are asking for. My example above shows that the date is the key to a new dictionary. In your example you are using a ,
instead of a :
, which is not possible.