diff options
author | BonfaceKilz | 2022-03-01 16:49:54 +0300 |
---|---|---|
committer | BonfaceKilz | 2022-03-12 15:33:09 +0300 |
commit | ba006bdd5ae2053575e11539186d5c5041f070c1 (patch) | |
tree | f956eff9d5db47d206af9cb4c3115fe83e1aece5 /gn3 | |
parent | 2b3494a8596f4978a64e03a8e1a1a033ac06b6b9 (diff) | |
download | genenetwork3-ba006bdd5ae2053575e11539186d5c5041f070c1.tar.gz |
Fill in empty values in csv text with: "x"
* gn3/csvcmp.py (fill_csv): Update this function to allow empty lists to be
filled with the default value(set in the args).
* tests/unit/test_csvcmp.py (test_fill_csv): Update test to capture above.
Diffstat (limited to 'gn3')
-rw-r--r-- | gn3/csvcmp.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/gn3/csvcmp.py b/gn3/csvcmp.py index 360a101..eef64b5 100644 --- a/gn3/csvcmp.py +++ b/gn3/csvcmp.py @@ -92,6 +92,10 @@ def fill_csv(csv_text, width, value="x"): if line.startswith("Strain") or line.startswith("#"): data.append(line) elif line: + _n = line.split(",") + for i, val in enumerate(_n): + if not val.strip(): + _n[i] = value data.append( - ",".join((_n:=line.split(",")) + [value] * (width - len(_n)))) + ",".join(_n + [value] * (width - len(_n)))) return "\n".join(data) |