about summary refs log tree commit diff
path: root/gn3
diff options
context:
space:
mode:
Diffstat (limited to 'gn3')
-rw-r--r--gn3/csvcmp.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/gn3/csvcmp.py b/gn3/csvcmp.py
index aa057b7..dd3f72b 100644
--- a/gn3/csvcmp.py
+++ b/gn3/csvcmp.py
@@ -118,3 +118,17 @@ def get_allowable_sampledata_headers(conn: Any) -> List:
         attributes += [attributes[0] for attributes in
                        cursor.fetchall()]
     return attributes
+
+
+def extract_invalid_csv_headers(allowed_headers: List, csv_text: str) -> List:
+    """Check whether a csv text's columns contains valid headers"""
+    csv_header = []
+    for line in csv_text.split("\n"):
+        if line.startswith("Strain Name"):
+            csv_header = [_l.strip() for _l in line.split(",")]
+            break
+    invalid_headers = []
+    for header in csv_header:
+        if header not in allowed_headers:
+            invalid_headers.append(header)
+    return invalid_headers