Skip to content

Latest commit

 

History

History
37 lines (29 loc) · 1.74 KB

csvio.rowprocessor.rst

File metadata and controls

37 lines (29 loc) · 1.74 KB

Row Processor

A Row Processor is used to transform the values of a row represented by a dictionary that maps column->value pairs. This processor is used in situations where you need to transform values of particular fields in a row depending upon the values of some other fields within the same row.

In csvio a CSV file is represented by a list of dictionaries that is populated in the rows attribute of the :py~csvio.CSVReader or :py~csvio.CSVWriter Classes.

Once instantiated, a Row Processor Object can be used by itself to process an arbitrary dictionary that represents a row or can be passed to the constructors of CSVReader </local_rw/csvio.csvreader> or CSVWriter </local_rw/csvio.csvwriter>.

In the case where a Row Processor Object is passed to the constructor of CSVReader </local_rw/csvio.csvreader>, it is applied to the rows of the CSVReader </local_rw/csvio.csvreader> as soon as they are read from the CSV file. See example code <csvreader_processors_usage> for further details.

Similarly, in the case where a Row Processor Object is passed to the constructor of CSVWriter </local_rw/csvio.csvwriter>, it is applied to the rows of the CSVWriter </local_rw/csvio.csvwriter> as soon as they are added for writing to the output CSV using its :py~csvio.CSVWriter.add_rows method. See example code <csvwriter_processors_usage> for further details.

csvio.processors.row_processor.RowProcessor