From 66960bdbd7cd313ebe5a7136568b7389dc7d7fed Mon Sep 17 00:00:00 2001 From: BonfaceKilz Date: Tue, 23 Nov 2021 17:20:18 +0300 Subject: wqflask: metadata_edits: Remove "\n\n" check with something else In excel, "\n\n" is replaced with ",,,," and this leads to a value error. --- wqflask/wqflask/metadata_edits.py | 13 +++++++++---- 1 file 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")) -- cgit v1.2.3