code: def write_csv_file(output_filename, tpip_pkgs):
      
      dirname = os.path.dirname(os.path.abspath(os.path.expanduser(output_filename)))
  
      if dirname and not os.path.exists(dirname):
          os.makedirs(dirname)
  
      with open(output_filename, 'w', newline='') as csvfile:
          writer = csv.DictWriter(csvfile, fieldnames=FIELDNAMES)
          writer.writeheader()
          writer.writerows(tpip_pkgs)
docs: Write the TPIP report out to a CSV file.
  
      :param str output_filename: filename for CSV.
      :param List tpip_pkgs: a list of dictionaries compatible with DictWriter.