bw_simapro_csv.csv_reader
Attributes
Classes
CSV reader which acts as a line by line iterator but which allows for one step backwards. |
Functions
|
Strip string, fix encoding, and remove undefined or control characters |
Module Contents
- class bw_simapro_csv.csv_reader.BeKindRewind(data_iterable: collections.abc.Iterator, clean_elements: bool = True, offset: int = 0)[source]
Bases:
collections.abc.IteratorCSV 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.
- Parameters:
data_iterable (collections.abc.Iterator) – Iterator which returns lists of strings.
clean_elements (bool, optional)
line (Do [clean(elem) for elem in line] when returning a new)