def _write_csv_output(note_phrase_matches, output_filename):
"""Write one CSV row for each phrase_match where the row contains all of
the RPDR note keys along with the extracted numerical value at the end of
the row."""
rpdr_rows_with_regex_value = []
for phrase_matches in note_phrase_matches:
row = phrase_matches.rpdr_note.get_keys()
if not phrase_matches.phrase_matches:
extracted_value = None
else:
extracted_value = phrase_matches.phrase_matches[0].extracted_value
row.append(extracted_value)
rpdr_rows_with_regex_value.append(row)
with open(output_filename, 'wb') as output_file:
csv_writer = csv.writer(output_file)
csv_writer.writerows(rpdr_rows_with_regex_value)
评论列表
文章目录