<commit_before>.. _io_registry:

I/O Registry
============

The I/O registry is a sub-module used to define the readers/writers available
for the :class:`~astropy.table.table.Table` and
:class:`~astropy.nddata.nddata.NDData` classes.

The following example demonstrates how to create a reader for the
:class:`~astropy.table.table.Table` class. First, we can create a highly
simplistic FITS reader which just reads the data as a structured array::

    from astropy.table import Table

    def fits_reader(filename, hdu=1):
        from astropy.io import fits
        data = fits.open(filename)[hdu].data
        return Table(data)

and then register it with astropy.table::

    from astropy.table import io_registry
    io_registry.register_reader('fits', fits_reader)

Reader functions can take any arguments except ``format`` (since this
is reserved for the ``Table.read`` method) and should return a
``Table`` object.

We can then read in a FITS table with::

    t = Table.read('catalog.fits', format='fits')

In practice, it would be nice to have the ``read`` method automatically<commit_msg>Added note for users about registry<commit_after>.. _io_registry:

I/O Registry
============

.. note:: The I/O registry is only meant to be used directly by users who want
          to define their own custom readers/writers. Users who want to find
          out more about what formats are supported by
          :class:`~astropy.table.table.Table` by default should see
          :ref:`table_io` (no formats are currently defined for
          :class:`~astropy.nddata.nddata.NDData`, but this will be added in
          future).

The I/O registry is a sub-module used to define the readers/writers available
for the :class:`~astropy.table.table.Table` and
:class:`~astropy.nddata.nddata.NDData` classes.

The following example demonstrates how to create a reader for the
:class:`~astropy.table.table.Table` class. First, we can create a highly
simplistic FITS reader which just reads the data as a structured array::

    from astropy.table import Table

    def fits_reader(filename, hdu=1):
        from astropy.io import fits
        data = fits.open(filename)[hdu].data
        return Table(data)

and then register it with `astropy.table`::

    from astropy.table import io_registry
    io_registry.register_reader('fits', fits_reader)

Reader functions can take any arguments except ``format`` (since this
is reserved for the ``Table.read`` method) and should return a
``Table`` object.

We can then read in a FITS table with::

    t = Table.read('catalog.fits', format='fits')

In practice, it would be nice to have the ``read`` method automatically
{'fraction_non_alphanumeric': 0.09590071455434374, 'fraction_numerical': 0.000752162467092892, 'mean_word_length': 3.7841726618705036, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '617249', 'n_tokens_mistral': 751, 'n_tokens_neox': 733, 'n_words': 310}