diff options
author | BonfaceKilz | 2022-03-01 15:41:56 +0300 |
---|---|---|
committer | BonfaceKilz | 2022-03-12 15:33:09 +0300 |
commit | b6ecd0888ccf51b1dd2bfcbbbc4e03b1c5a92699 (patch) | |
tree | 59801fba61b68fb9d3f21e6441d033a57ac592b0 /gn3/csvcmp.py | |
parent | 59d2d0a8175c4a06c5363a8a3d3addd683ef9a8d (diff) | |
download | genenetwork3-b6ecd0888ccf51b1dd2bfcbbbc4e03b1c5a92699.tar.gz |
Extract a strain name given a csv string and it's header
* gn3/csvcmp.py (extract_strain_name): New function.
* gn3/db/sample_data (delete_sample_data): Use the aforementioned function.
(insert_sample_data): Ditto.
* tests/unit/test_csvcmp: Test cases for above.
Diffstat (limited to 'gn3/csvcmp.py')
-rw-r--r-- | gn3/csvcmp.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/gn3/csvcmp.py b/gn3/csvcmp.py index ebd323e..360a101 100644 --- a/gn3/csvcmp.py +++ b/gn3/csvcmp.py @@ -4,6 +4,13 @@ import uuid from gn3.commands import run_cmd +def extract_strain_name(csv_header, data, seek="Strain Name"): + for column, value in zip(csv_header.split(","), data.split(",")): + if seek in column: + return value + return "" + + def create_dirs_if_not_exists(dirs: list): for dir_ in dirs: if not os.path.exists(dir_): |