Skip to content

Commit

Permalink
fix: pandas file handling depending on version
Browse files Browse the repository at this point in the history
  • Loading branch information
thomas-reimonn authored and nvictus committed Feb 1, 2024
1 parent f022baa commit f309973
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions src/cooler/cli/cload.py
Original file line number Diff line number Diff line change
Expand Up @@ -582,17 +582,14 @@ def pairs(
kwargs = {}
if pairs_path == "-":
f_in = sys.stdin
_, f_in = get_header(f_in)
elif int(_pandas_version[0]) > 0:
if int(_pandas_version[0]) < 2:
f_in = get_handle(pairs_path, mode="r", compression="infer")[0]
else:
f_in = get_handle(pairs_path, mode="r", compression="infer").handle

_, f_in = get_header(f_in)
elif int(_pandas_version[0]) == 1 and int(_pandas_version[1]) < 2:
# get_handle returns a pair of objects in pandas 1.0 and 1.1
f_in = get_handle(pairs_path, mode="r", compression="infer")[0]
else:
f_in = pairs_path
kwargs["comment"] = "#"
# get_handle returns a single wrapper object in pandas 1.2+ and 2.*
f_in = get_handle(pairs_path, mode="r", compression="infer").handle

_, f_in = get_header(f_in)

reader = pd.read_csv(
f_in,
Expand Down

0 comments on commit f309973

Please sign in to comment.