csv files the csv dictreader class as well as the csv dictwriter there is csv dictreader the file to be used with the dictreader is provided when the class is instantiated as with the dictreader the dictwriter class takes list of keys used to define the columns in the csv file if the headings to be used for the first row can be provided although this is optional (if set of keys are not providedthen the values in the first row of the csv file will be used as the fieldnamesthe dictreader class provides several useful features including the fieldnames property that contains list of the keys/headings for the csv file as defined by the first row of the file the dictreader class also implements the iteration protocol and thus it can be used in for loop in which each row (after the first rowis returned in turn as dictionary the dictionary object representing each row can then be used to access each column value based on the keys defined in the first row an example is shown below for the csv file created earlierimport csv print('starting to read dict csv example'with open('names csv'newline=''as csvfilereader csv dictreader(csvfilefor heading in reader fieldnamesprint(headingend='print('\ 'for row in readerprint(row['first_name']row['last_name']row['result']print('done'