Last week we refactored some Python code that parses CSV files and loads records into a database. We ended up with two general groups of code.
One group (lines 24 - 43) is a series of small functions that extract various data types (booleans, timestamps, etc) from CSV fields. The other group is a large function (lines 46 - 92) that extracts individual fields and builds a model object. I expressed frustration that this latter function was so long.
def build_nessus_object(row, heading_map):
"""process a row of data and return a Nessus object"""
# parameters which are processed as-is from the csv
normal_params = {
'plugin' : 'Plugin',