Skip to content

Commit

Permalink
fix(read): handle filenames with dots confusing with extension
Browse files Browse the repository at this point in the history
  • Loading branch information
chanshing committed Feb 5, 2024
1 parent 85ee34d commit 1e89ceb
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/stepcount/stepcount.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,8 +333,10 @@ def nanint(x):
def read(filepath, resample_hz='uniform', sample_rate=None, verbose=True):

p = pathlib.Path(filepath)
ftype = p.suffixes[0].lower()
fsize = round(p.stat().st_size / (1024 * 1024), 1)
ftype = p.suffix.lower()
if ftype in (".gz", ".xz", ".lzma", ".bz2", ".zip"): # if file is compressed, check the next extension
ftype = pathlib.Path(p.stem).suffix.lower()

if ftype in (".csv", ".pkl"):

Expand Down Expand Up @@ -386,6 +388,9 @@ def read(filepath, resample_hz='uniform', sample_rate=None, verbose=True):
verbose=verbose,
)

else:
raise ValueError(f"Unknown file format: {ftype}")

if 'ResampleRate' not in info:
info['ResampleRate'] = info['SampleRate']

Expand Down

0 comments on commit 1e89ceb

Please sign in to comment.