code: def output_results(results, mvdelim = '\n', output = sys.stdout):
      
  
      # We collect all the unique field names, as well as 
      # convert all multivalue keys to the right form
      fields = set()
      for result in results:    
          for key in result.keys():
              if(isinstance(result[key], list)):
                  result['__mv_' + key] = encode_mv(result[key])
                  result[key] = mvdelim.join(result[key])
          fields.update(list(result.keys()))
  
      # convert the fields into a list and create a CSV writer
      # to output to stdout
      fields = sorted(list(fields))
  
      writer = csv.DictWriter(output, fields)
  
      # Write out the fields, and then the actual results
      writer.writerow(dict(list(zip(fields, fields))))
      writer.writerows(results)
docs: Given a list of dictionaries, each representing
      a single result, and an optional list of fields,
      output those results to stdout for consumption by the
      Splunk pipeline