Skip to content

Commit

Permalink
CSVSolinstFileReader: comment the changes made in PR#62
Browse files Browse the repository at this point in the history
  • Loading branch information
jnsebgosselin committed Apr 8, 2021
1 parent 1bcc0be commit 5db8d39
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -476,8 +476,13 @@ def _get_date_list(self) -> list:
iend += 1
fmt += ".{}"

datetimes = []
# We store the line indexes corresponding to valid dates in the
# record, so that we can retrieve the numerical data at these specific
# indexes later in _get_data. This is required in case there is
# blank lines or badly formatted dates in the record.
# See cgq-qgc/HydroSensorReader#62.
self._data_content_indexes = []
datetimes = []
data_content = self.file_content[self._start_of_data_row_index + 1:]
for i, line in enumerate(data_content):
try:
Expand Down Expand Up @@ -582,8 +587,11 @@ def _get_parameter_data(self):
def _get_data(self):
"""Retrieve the numerical data from the Solinst data file."""
self._get_parameter_data()

data = [self.file_content[i] for i in self._data_content_indexes]

# We go over each row of data and pad with nan values when needed
# to make sure each row has the same length.
# See cgq-qgc/HydroSensorReader#62.
pad = len(max(data, key=len))
data = np.array([row + [np.nan] * (pad - len(row)) for row in data])

Expand Down

0 comments on commit 5db8d39

Please sign in to comment.