
.. DO NOT EDIT.
.. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY.
.. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE:
.. "gallery/misc/load_converter.py"
.. LINE NUMBERS ARE GIVEN BELOW.

.. only:: html

    .. note::
        :class: sphx-glr-download-link-note

        Click :ref:`here <sphx_glr_download_gallery_misc_load_converter.py>`
        to download the full example code

.. rst-class:: sphx-glr-example-title

.. _sphx_glr_gallery_misc_load_converter.py:


==============
Load converter
==============

This example demonstrates passing a custom converter to `numpy.genfromtxt` to
extract dates from a CSV file.

.. GENERATED FROM PYTHON SOURCE LINES 9-27



.. image:: /gallery/misc/images/sphx_glr_load_converter_001.png
    :alt: load converter
    :class: sphx-glr-single-img


.. rst-class:: sphx-glr-script-out

 Out:

 .. code-block:: none

    loading /build/matplotlib-eAPYn3/matplotlib-3.3.4/build/lib.linux-x86_64-3.9/matplotlib/mpl-data/sample_data/msft.csv






|

.. code-block:: default


    import dateutil.parser
    from matplotlib import cbook
    import matplotlib.pyplot as plt
    import numpy as np


    datafile = cbook.get_sample_data('msft.csv', asfileobj=False)
    print('loading', datafile)

    data = np.genfromtxt(
        datafile, delimiter=',', names=True,
        dtype=None, converters={0: dateutil.parser.parse})

    fig, ax = plt.subplots()
    ax.plot(data['Date'], data['High'], '-')
    fig.autofmt_xdate()
    plt.show()


.. _sphx_glr_download_gallery_misc_load_converter.py:


.. only :: html

 .. container:: sphx-glr-footer
    :class: sphx-glr-footer-example



  .. container:: sphx-glr-download sphx-glr-download-python

     :download:`Download Python source code: load_converter.py <load_converter.py>`



  .. container:: sphx-glr-download sphx-glr-download-jupyter

     :download:`Download Jupyter notebook: load_converter.ipynb <load_converter.ipynb>`


.. only:: html

 .. rst-class:: sphx-glr-signature

    Keywords: matplotlib code example, codex, python plot, pyplot
    `Gallery generated by Sphinx-Gallery
    <https://sphinx-gallery.readthedocs.io>`_
