Hi All--


I am trying to read a csv file via DictReader and produce a single
dictionary without fieldnames; that is, I just want a single dictionary
that contains tests as keys and grades as values as shown below in my
sample file.



If I loop through the reader, it produces a sequence of 2 entries
dictionaries; each starts with the fieldnames, e.g. {Test:Test1,Grade:A},
etc.

I want to create a single dictionary with only Tests and Grades; that’s
{Test1:A,Test2:b,Test3:c etc.}. I tried several ways but nothing worked.





File



Test     Grade

Test1   A

Test2   B

Test3   C



Code;



import csv

with open(Tests.csv, 'r') as Temp:

   reader = csv.DictReader(Temp)
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to