Skip to content

Latest commit

 

History

History
40 lines (31 loc) · 1.9 KB

csvio.fieldprocessor.rst

File metadata and controls

40 lines (31 loc) · 1.9 KB

Field Processor

A Field Processor is used to transform the values in a row represented by a dictionary that maps column->value pairs. This processor can be used to transform the values of particular fields in a row, where the values of other fields in the row are not required for making the transformation.

Row Processors <csvio.rowprocessor> can be used to make transformations where values of other fields within the same row are required.

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 Field 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 Field 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 Field 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.field_processor.FieldProcessor