From 8210007122c26daffcfbbb159ff846b928dfb18d Mon Sep 17 00:00:00 2001 From: BonfaceKilz Date: Wed, 24 Nov 2021 11:32:49 +0300 Subject: db: traits: Remove trailing ".0" in int values --- gn3/db/traits.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'gn3/db') diff --git a/gn3/db/traits.py b/gn3/db/traits.py index 56258e2..ebb7e3c 100644 --- a/gn3/db/traits.py +++ b/gn3/db/traits.py @@ -79,6 +79,11 @@ def export_trait_data( def get_trait_csv_sample_data(conn: Any, trait_name: int, phenotype_id: int): """Fetch a trait and return it as a csv string""" + + def __float_strip(n): + if str(n)[-2:] == ".0": + return str(int(n)) + return str(n) sql = ("SELECT DISTINCT Strain.Id, PublishData.Id, Strain.Name, " "PublishData.value, " "PublishSE.error, NStrain.count FROM " @@ -100,7 +105,7 @@ def get_trait_csv_sample_data(conn: Any, (strain_id, publishdata_id, strain_name, value, error, count) = record csv_data.append( - ",".join([str(val) if val else "x" + ",".join([__float_strip(val) if val else "x" for val in (strain_id, strain_name, value, error, count)])) return f"# Publish Data Id: {publishdata_id}\n" + "\n".join(csv_data) -- cgit v1.2.3