diff options
author | BonfaceKilz | 2021-11-23 17:20:18 +0300 |
---|---|---|
committer | BonfaceKilz | 2021-11-23 17:44:24 +0300 |
commit | 66960bdbd7cd313ebe5a7136568b7389dc7d7fed (patch) | |
tree | be1d627fb971bcc3a6da02ff3dfbf6a2083a7150 | |
parent | c398af6b98f89917065457153b0f7e55be28e835 (diff) | |
download | genenetwork2-66960bdbd7cd313ebe5a7136568b7389dc7d7fed.tar.gz |
wqflask: metadata_edits: Remove "\n\n" check with something else
In excel, "\n\n" is replaced with ",,,," and this leads to a value
error.
-rw-r--r-- | wqflask/wqflask/metadata_edits.py | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/wqflask/wqflask/metadata_edits.py b/wqflask/wqflask/metadata_edits.py index 572db080..21b73cb4 100644 --- a/wqflask/wqflask/metadata_edits.py +++ b/wqflask/wqflask/metadata_edits.py @@ -1,6 +1,7 @@ import datetime import json import os +import re from collections import namedtuple from itertools import groupby @@ -250,17 +251,21 @@ def update_phenotype(dataset_id: str, name: str): file_.save(new_file_name) publishdata_id = "" lines = [] + split_point = "" with open(new_file_name, "r") as f: lines = f.read() - first_line = lines.split('\n', 1)[0] - publishdata_id = first_line.split("Id:")[-1].strip() + for line in lines.split("\n"): + if "# Publish Data Id:" in line: + split_point = line + publishdata_id = re.findall(r'\b\d+\b', line)[0] + break with open(new_file_name, "w") as f: - f.write(lines.split("\n\n")[-1]) + f.write(lines.split(f"{split_point}\n")[-1].strip()) csv_ = get_trait_csv_sample_data(conn=conn, trait_name=str(name), phenotype_id=str(phenotype_id)) with open(uploaded_file_name, "w") as f_: - f_.write(csv_.split("\n\n")[-1]) + f_.write(csv_.split(str(publishdata_id))[-1].strip()) r = run_cmd(cmd=("csvdiff " f"'{uploaded_file_name}' '{new_file_name}' " "--format json")) |