Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions wfdb/io/_header.py
Original file line number Diff line number Diff line change
Expand Up @@ -756,9 +756,25 @@ def wr_header_file(self, write_fields, write_dir):
for field in RECORD_SPECS.index:
# If the field is being used, add it with its delimiter
if field in write_fields:
record_line += RECORD_SPECS.loc[field, "delimiter"] + str(
getattr(self, field)
string_field = str(getattr(self, field))

# Certain fields need extra processing
if field == "fs" and isinstance(self.fs, float):
if round(self.fs, 8) == float(int(self.fs)):
string_field = str(int(self.fs))
elif field == "base_time" and "." in string_field:
string_field = string_field.rstrip("0")
elif field == "base_date":
string_field = "/".join(
(string_field[8:], string_field[5:7], string_field[:4])
)

record_line += (
RECORD_SPECS.loc[field, "delimiter"] + string_field
)
# The 'base_counter' field needs to be closed with ')'
if field == "base_counter":
record_line += ")"

header_lines = [record_line]

Expand Down