def generate_flattened_dict(headers, results):
for name, values in results.items():<EOL><INDENT>row = []<EOL>for header in headers:<EOL><INDENT>if header == '<STR_LIT:name>':<EOL><INDENT>row.append(name)<EOL><DEDENT>elif '<STR_LIT::>' in header:<EOL><INDENT>neurite_type, metric = header.split('<STR_LIT::>')<EOL>row.append(values[neurite_type][metric])<EOL><DEDENT>else:<EOL><INDENT>row.append(values[header])<EOL><DEDENT><DEDENT>yield row<EOL><DEDENT>
extract from results the fields in the headers list