def write_csv(results, headers, filename):
 with open(filename, 'w') as csvfile:
  writer = csv.DictWriter(csvfile, fieldnames=headers)
  writer.writeheader()
  writer.writerows(results)

def write_csv ( results , headers , filename ) : with open ( filename , 'w' ) as csvfile : writer = csv . DictWriter ( csvfile , fieldnames = headers ) writer . writeheader ( ) writer . writerows ( results )
write a set of results to a csv file .