code: def export(results_dir, filename, do_not_try_parsing, parameters):
      
  
      # Get the extension
      _, extension = os.path.splitext(filename)
  
      campaign = sem.CampaignManager.load(results_dir)
  
      [params, defaults] = zip(*get_params_and_defaults(campaign.db.get_params(),
                                                        campaign.db))
  
      if do_not_try_parsing:
          parsing_function = None
      else:
          parsing_function = sem.utils.automatic_parser
  
      if not parameters:
          # Convert to string
          string_defaults = list()
          for idx, d in enumerate(defaults):
              string_defaults.append(str(d))
          parameter_query = query_parameters(params, string_defaults)
      else:
          # Import specified parameter file
          parameter_query = import_parameters_from_file(parameters)
  
      if extension == ".mat":
          campaign.save_to_mat_file(parameter_query, parsing_function, filename,
                                    runs=click.prompt("Runs", type=int))
      elif extension == ".npy":
          campaign.save_to_npy_file(parameter_query, parsing_function, filename,
                                    runs=click.prompt("Runs", type=int))
      elif extension == "":
          campaign.save_to_folders(parameter_query, filename,
                                   runs=click.prompt("Runs", type=int))
      else:  # Unrecognized format
          raise ValueError("Format not recognized")
docs: Export results to file.
  
      An extension in filename is required to deduce the file type. If no
      extension is specified, a directory tree export will be used. Note that
      this command automatically tries to parse the simulation output.
  
      Supported extensions:
  
      .mat (Matlab file),
      .npy (Numpy file),
      no extension (Directory tree)