safe_open_dict_writer

safe_open_dict_writer(f: str | Path | TextIO, fieldnames: Sequence[str], *, delimiter: str = '\t', **kwargs: Any) Generator[DictWriter[str], None, None][source]

Open a CSV dictionary writer, wrapping csv.DictWriter().

Parameters:
  • f – A path to a file, or an already open text-based IO object

  • fieldnames – A path to a file, or an already open text-based IO object

  • delimiter – The delimiter for writing to CSV

  • kwargs – Keyword arguments to pass to csv.DictWriter()

Yields:

A CSV dictionary writer object, constructed from csv.DictWriter()