Skip to content

Commit

Permalink
extract basename and remove extension with os.path.basename and os.pa…
Browse files Browse the repository at this point in the history
…th.splitext.
  • Loading branch information
tompollard committed Jul 3, 2024
1 parent 530e67d commit 8463fe6
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions wfdb/io/convert/csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,16 +325,14 @@ def csv_to_wfdb(
print("Signal names: {}".format(sig_name))

# Determine the output directory
base_name = os.path.splitext(os.path.basename(file_name))[0]

if write_dir:
if not os.path.exists(write_dir):
os.makedirs(write_dir)
output_base = os.path.join(
write_dir, os.path.basename(file_name).replace(".csv", "")
)
output_base = os.path.join(write_dir, base_name)
else:
if os.sep in file_name:
file_name = file_name.split(os.sep)[-1]
output_base = file_name.replace(".csv", "")
output_base = base_name

if verbose:
print("Output base: {}".format(output_base))
Expand Down

0 comments on commit 8463fe6

Please sign in to comment.