Skip to content

Commit

Permalink
potentail resolution for issue 45
Browse files Browse the repository at this point in the history
  • Loading branch information
CDJellen committed Oct 16, 2024
1 parent a478630 commit 92e2633
Show file tree
Hide file tree
Showing 2 changed files with 118 additions and 115 deletions.
5 changes: 3 additions & 2 deletions ndbc_api/api/parsers/http/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class BaseParser:
HEADER_PREFIX = '#'
NAN_VALUES = ['MM']
DATE_PARSER = '%Y %m %d %H %M'
PARSE_DATES = ['YY', 'MM', 'DD', 'hh', 'mm']
PARSE_DATES = [0, 1, 2, 3, 4]
INDEX_COL = False
REVERT_COL_NAMES = []

Expand Down Expand Up @@ -43,7 +43,7 @@ def _read_response(cls, response: dict,
if not data:
return pd.DataFrame()
# check that parsed names match parsed values or revert
if len([v.strip() for v in data[0].split(' ') if v]) != len(names):
if len([v.strip() for v in data[0].strip('\n').split(' ') if v]) != len(names):
names = cls.REVERT_COL_NAMES
if '(' in data[0]:
data = cls._clean_data(data)
Expand All @@ -67,6 +67,7 @@ def _read_response(cls, response: dict,
df.index.name = 'timestamp'

except (NotImplementedError, TypeError, ValueError) as e:
print(e)
return pd.DataFrame()

# check whether to parse dates
Expand Down
Loading

0 comments on commit 92e2633

Please sign in to comment.