def write_key_value_file(csvfile, dictionary, append=False):
 writer = csv.writer(csvfile, delimiter=',')
 if (not append):
  writer.writerow(['key', 'value'])
 for (key, val) in dictionary.items():
  writer.writerow([key, val])

def write_key_value_file ( csvfile , dictionary , append = False ) : writer = csv . writer ( csvfile , delimiter = ',' ) if ( not append ) : writer . writerow ( [ 'key' , 'value' ] ) for ( key , val ) in dictionary . items ( ) : writer . writerow ( [ key , val ] )
writes a dictionary to a writable file in a csv format args: csvfile : writable file dictionary : dictionary containing key-value pairs append : writes key .