Skip to content

Commit d9f4e3c

Browse files
committed
extract basename and remove extension with os.path.basename and os.path.splitext.
1 parent a5d50c2 commit d9f4e3c

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

wfdb/io/convert/csv.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -325,16 +325,14 @@ def csv_to_wfdb(
325325
print("Signal names: {}".format(sig_name))
326326

327327
# Determine the output directory
328+
base_name = os.path.splitext(os.path.basename(file_name))[0]
329+
328330
if write_dir:
329331
if not os.path.exists(write_dir):
330332
os.makedirs(write_dir)
331-
output_base = os.path.join(
332-
write_dir, os.path.basename(file_name).replace(".csv", "")
333-
)
333+
output_base = os.path.join(write_dir, base_name)
334334
else:
335-
if os.sep in file_name:
336-
file_name = file_name.split(os.sep)[-1]
337-
output_base = file_name.replace(".csv", "")
335+
output_base = base_name
338336

339337
if verbose:
340338
print("Output base: {}".format(output_base))

0 commit comments

Comments
 (0)