Skip to content

Commit

Permalink
Support for windows-1252 encoded CSV reads. Measurement files and res…
Browse files Browse the repository at this point in the history
…ults for squig.link sites.
  • Loading branch information
jaakkopasanen committed Dec 3, 2023
1 parent 87683b5 commit eab138a
Show file tree
Hide file tree
Showing 14 changed files with 4,023 additions and 995 deletions.
8 changes: 6 additions & 2 deletions autoeq/frequency_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,12 @@ def to_dict(self):
def read_csv(cls, file_path):
"""Reads data from CSV file and constructs class instance."""
name = '.'.join(Path(file_path).name.split('.')[:-1])
with open(file_path, 'r', encoding='utf-8') as fh:
csv_str = fh.read().strip()
try:
with open(file_path, 'r', encoding='utf-8') as fh:
csv_str = fh.read().strip()
except UnicodeDecodeError as err:
with open(file_path, 'r', encoding='windows-1252') as fh:
csv_str = fh.read().strip()
return cls(name=name, **parse_csv(csv_str))

def write_csv(self, file_path):
Expand Down
Loading

0 comments on commit eab138a

Please sign in to comment.