format = {}
types = {'Real': float, 'Character': str, 'Integer': int}
for line in open('format.txt', 'r'):
    values = line.split('\t')
range = values[1].split('-')
format[values[0]] = {'start': int(range[0]) - 1, 'end': int(range[1]) - 1,
    'type': types[values[2]]}
results = []
for line in open('filename.txt'):
    result = {}
for key in format:
    result[key] = format['type'](line[format['start']:format['end']])
results.append(result)
Python Чтение форматированной строки