.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/composition/eval_csv.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_examples_composition_eval_csv.py: Transformer for evaluating csv.lark .. GENERATED FROM PYTHON SOURCE LINES 2-27 .. code-block:: default from lark import Transformer class CsvTreeToPandasDict(Transformer): INT = int FLOAT = float SIGNED_FLOAT = float WORD = str NON_SEPARATOR_STRING = str def row(self, children): return children def start(self, children): data = {} header = children[0].children for heading in header: data[heading] = [] for row in children[1:]: for i, element in enumerate(row): data[header[i]].append(element) return data .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.000 seconds) .. _sphx_glr_download_examples_composition_eval_csv.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: eval_csv.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: eval_csv.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_