def csv_mapping_parser(path, template):
 mapping_blocks = defaultdict(dict)
 with open(path, 'r') as handle:
  reader = csv.reader(handle)
  reader.next()
  for row in reader:
   mapping = dict(zip(template, row))
   fid = mapping.pop('function')
   aid = int(mapping['address'])
   mapping_blocks[aid] = mapping
 return mapping_blocks

def csv_mapping_parser ( path , template ) : mapping_blocks = defaultdict ( dict ) with open ( path , 'r' ) as handle : reader = csv . reader ( handle ) reader . next ( ) for row in reader : mapping = dict ( zip ( template , row ) ) fid = mapping . pop ( 'function' ) aid = int ( mapping [ 'address' ] ) mapping_blocks [ aid ] = mapping return mapping_blocks
given a csv file of the the mapping data for a modbus device .