From 303f9851c49a75dcfa613b815d35cd79f72307e0 Mon Sep 17 00:00:00 2001 From: Christian Gill Date: Mon, 27 Jul 2020 14:02:08 +0200 Subject: [PATCH] allow for uploading empty label testcase for empty label --- app/api/tests/data/example.csv | 3 ++- app/api/utils.py | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/api/tests/data/example.csv b/app/api/tests/data/example.csv index 69cfabd1..3ff73519 100644 --- a/app/api/tests/data/example.csv +++ b/app/api/tests/data/example.csv @@ -1,4 +1,5 @@ text,label,meta AAA BBB,Positive,The following is meta data -CCC,Negative \ No newline at end of file +CCC,Negative +DDD,,This is meta data \ No newline at end of file diff --git a/app/api/utils.py b/app/api/utils.py index 194a63ed..03bbe118 100644 --- a/app/api/utils.py +++ b/app/api/utils.py @@ -392,7 +392,10 @@ class ExcelParser(FileParser): datum = dict(zip(columns, row)) text, label = datum.pop('text'), datum.pop('label') meta = FileParser.encode_metadata(datum) - j = {'text': text, 'labels': [label], 'meta': meta} + if label != '': + j = {'text': text, 'labels': [label], 'meta': meta} + else: + j = {'text': text, 'meta': meta} data.append(j) else: raise FileParseException(line_num=i, line=row)