Skip to main content
`Ctrl`+`K`

# write

astropy.io.ascii.write(table, output=None, format=None, fast_writer=True, *, overwrite=False, **kwargs)

  Write the input `table` to `filename`. Most of the default behavior for various parameters is determined by the Writer class.

  Help on the `write()` function arguments is available as shown in this example:

      from astropy.io import ascii
      ascii.write.help()  # Common help for all formats
      ascii.write.help("html")  # Common help plus "html" format-specific args

  See also:

  - https://docs.astropy.org/en/stable/io/ascii/

  - https://docs.astropy.org/en/stable/io/ascii/write.html

  Parameters:
    table `BaseReader`, numpy:array_like, `python:str`, python:file-like object, `python:list`

      Input table as a Reader object, Numpy struct array, file name, file-like object, list of strings, or single newline-separated string.

    output `python:str`, python:file-like object

      Output [filename, file-like object]. Defaults to``sys.stdout``.

    format `python:str`

      Output table format. Defaults to ‘basic’.

    delimiter `python:str`

      Column delimiter string

    comment `python:str`, bool

      String defining a comment line in table. If `False` then comments are not written out.

    quotechar `python:str`

      One-character string to quote fields containing special characters

    formats `python:dict`

      Dictionary of format specifiers or formatting functions

    strip_whitespace bool

      Strip surrounding whitespace from column values.

    names `python:list`

      List of names corresponding to each data column

    include_names `python:list`

      List of names to include in output.

    exclude_names `python:list`

      List of names to exclude from output (applied after `include_names`)

    fast_writer bool, `python:str`

      Whether to use the fast Cython writer. Can be `True` (use fast writer if available), `False` (do not use fast writer), or `'force'` (use fast writer and fail if not available, mostly for testing).

    overwrite bool

      If `overwrite=False` (default) and the file exists, then an OSError is raised. This parameter is ignored when the `output` arg is not a string (e.g., a file object).