Skip to content

Commit

Permalink
fix: BOM in files
Browse files Browse the repository at this point in the history
  • Loading branch information
mjaquiery committed Jun 19, 2024
1 parent be6c9c9 commit 8e09200
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/galv_harvester/parse/arbin.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def __init__(self, file_path, **kwargs):
def load_data(self, file_path, columns):
column_names = self.header

with open(file_path, newline='') as csvfile:
with open(file_path, newline='', encoding='utf-8-sig') as csvfile:
reader = csv.reader(csvfile, dialect=self.dialect)
next(reader)
for row in reader:
Expand Down
4 changes: 2 additions & 2 deletions src/galv_harvester/parse/delimited_input_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def __init__(self, file_path, **kwargs):
:raises UnsupportedFileTypeError: if the file is not a supported type
"""
with open(file_path, newline='') as csvfile:
with open(file_path, newline='', encoding='utf-8-sig') as csvfile:
last_line = 0
chunk_size = 1024
lines_to_check = 100
Expand Down Expand Up @@ -103,7 +103,7 @@ def load_data(self, file_path, columns):

column_names = [self.header[i] for i in column_numbers]

with open(file_path, newline='') as csvfile:
with open(file_path, newline='', encoding='utf-8-sig') as csvfile:
self.spin_to_line(csvfile, self.data_start)
reader = csv.reader(csvfile, dialect=self.dialect)
if self.has_header:
Expand Down
6 changes: 3 additions & 3 deletions src/galv_harvester/parse/maccor_input_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def load_data(self, file_path, columns):
Load data in a maccor csv or tsv file"
"""

with open(file_path, "r") as csvfile:
with open(file_path, "r", encoding='utf-8-sig') as csvfile:
# get rid of metadata rows
csvfile.readline()
if self.num_header_rows > 1:
Expand Down Expand Up @@ -305,7 +305,7 @@ def get_data_labels(self):
)

def is_maccor_text_file(self, file_path, delimiter):
with open(file_path, "r") as f:
with open(file_path, "r", encoding='utf-8-sig') as f:
line = f.readline()
line_start = "Today''s Date" + delimiter
date_regex = r"\d\d\/\d\d\/\d\d\d\d \d?\d:\d\d:\d\d [AP]M"
Expand Down Expand Up @@ -585,7 +585,7 @@ def load_metadata(self):

def validate_file(self, file_path):
self.logger.debug('is_maccor_raw_file')
with open(file_path, "r") as f:
with open(file_path, "r", encoding='utf-8-sig') as f:
self.logger.debug('got line')
line = f.readline()
self.logger.debug('got line', line)
Expand Down

0 comments on commit 8e09200

Please sign in to comment.