original_docstring: Write data to a csv file with labelled columns.
  
      Arguments:
          filename -- string of the file name, including the extension
          fieldnames -- a list of column names
          data -- a list of lists; each sublist is one row in the csv file,
                  and should be as long as the fieldnames
      
docstring: Write data to a csv file with labelled columns.
docstring_tokens: Write data to a csv file with labelled columns .
code: def write_data(filename, fieldnames, data):
      """Write data to a csv file with labelled columns.
  
      Arguments:
          filename -- string of the file name, including the extension
          fieldnames -- a list of column names
          data -- a list of lists; each sublist is one row in the csv file,
                  and should be as long as the fieldnames
      """
      with open(filename, 'w') as csvfile:
          writer = csv.DictWriter(csvfile, fieldnames = fieldnames)
          writer.writeheader()
          print(fieldnames)
          for datum in data:
              print(data)
  
              writer.writerow(dict([(fieldnames[i], datum[i]) for i in range(0, len(fieldnames))]))
      print('Data saved successfully.')
code_tokens: def write_data ( filename , fieldnames , data ) : with open ( filename , 'w' ) as csvfile : writer = csv . DictWriter ( csvfile , fieldnames = fieldnames ) writer . writeheader ( ) print ( fieldnames ) for datum in data : print ( data ) writer . writerow ( dict ( [ ( fieldnames [ i ] , datum [ i ] ) for i in range ( 0 , len ( fieldnames ) ) ] ) ) print ( 'Data saved successfully.' )
short_docstring: Write data to a csv file with labelled columns.
short_docstring_tokens: Write data to a csv file with labelled columns .
comment: """Write data to a csv file with labelled columns.
  
      Arguments:
          filename -- string of the file name, including the extension
          fieldnames -- a list of column names
          data -- a list of lists; each sublist is one row in the csv file,
                  and should be as long as the fieldnames
      """