bw_simapro_csv.csv_reader ========================= .. py:module:: bw_simapro_csv.csv_reader Attributes ---------- .. autoapisummary:: bw_simapro_csv.csv_reader.CONTROL_CHARACTERS bw_simapro_csv.csv_reader.UNDEFINED bw_simapro_csv.csv_reader.WARNING_CHARS Classes ------- .. autoapisummary:: bw_simapro_csv.csv_reader.BeKindRewind Functions --------- .. autoapisummary:: bw_simapro_csv.csv_reader.clean Module Contents --------------- .. py:class:: BeKindRewind(data_iterable: collections.abc.Iterator, clean_elements: bool = True, offset: int = 0) Bases: :py:obj:`collections.abc.Iterator` CSV reader which acts as a line by line iterator but which allows for one step backwards. Needed because the file we are consuming will sometimes indicate that a logical block is finished by using the control word `End`, but other times won't. In that case, our iterator is already in a new block. To make it simple to pass the iterator to the next function consuming the new block, we rewind it one line. Internally this is implemented by caching the last line read, and using `itertools.chain` when needed to prepend the cached line to the iterator. :param data_iterable: Iterator which returns lists of strings. :type data_iterable: collections.abc.Iterator :param clean_elements: :type clean_elements: bool, optional :param Do `[clean(elem) for elem in line]` when returning a new line: .. py:method:: rewind() -> None Rewinds the iterator by one step, retrieving the element that was just returned by the previous call to `__next__`. .. py:attribute:: clean_elements :value: True .. py:attribute:: current :value: None .. py:attribute:: data_iterable .. py:attribute:: line_no :value: 1 .. py:function:: clean(s: str) -> str Strip string, fix encoding, and remove undefined or control characters .. py:data:: CONTROL_CHARACTERS .. py:data:: UNDEFINED .. py:data:: WARNING_CHARS :value: 'À˜â¿'