Skip to content

Instantly share code, notes, and snippets.

@canimus
Created February 9, 2023 14:10
Show Gist options
  • Select an option

  • Save canimus/1b23464a40d900361410fde5e6e71c69 to your computer and use it in GitHub Desktop.

Select an option

Save canimus/1b23464a40d900361410fde5e6e71c69 to your computer and use it in GitHub Desktop.

Revisions

  1. canimus created this gist Feb 9, 2023.
    31 changes: 31 additions & 0 deletions gen_sample.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,31 @@
    series = []
    d = {}
    for row in raw:
    try:
    if len(row) == 0:
    continue
    if row.startswith("!sample_table_end"):
    for k in arr:
    if k in d:
    d[k] = [d[k]]
    series.append(d)
    d = {}
    continue
    if row.startswith("#") or row.startswith("ID_REF") or ("sample_table_begin" in row):
    continue
    if row.startswith("^") or row.startswith("!"):
    x = row.split(" ")
    a,b = x[0].strip(), " ".join(x[1:]).strip()
    if a in arr:
    if a not in d:
    d[a] = []
    else:
    d[a] = d[a] + [b[2:]]
    else:
    d[a] = [b[2:]]
    else:
    a,b = row.split("\t")
    d[a.strip()] = [b.strip()]
    except Exception as e:
    print(row, e)
    break