Commit 5638ebe9 authored by Merlijn Wajer's avatar Merlijn Wajer
Browse files

Add parse_csv: rudimentary script to parse csv result files created by operators

parent ff082fe8
import csv
import sys
import re
reader = csv.DictReader(open(sys.argv[1]))
LEAF_ROW_1 = 'bad crop leaf and note'
LEAF_ROW_2 = 'Ok but could use improvement'
LEAF_RE = '\d+'
reslist = []
for row in reader:
leafs = re.findall(LEAF_RE, row[LEAF_ROW_1])
leafs += re.findall(LEAF_RE, row[LEAF_ROW_2])
leafs = list(map(int, leafs))
leafs = list(map(str, leafs))
identifier = row['identifier']
type_ = 'train'
pages = ','.join(leafs)
reason = row[LEAF_ROW_1] + row[LEAF_ROW_2]
reslist.append({'identifier': identifier,
'type': type_,
'pages': pages,
'reason': reason})
import yaml
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment