Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

StationHourlyDataIO request thows attributeerror: 'hourlyDataValue' object has no attribute 'items' when running the example #14

Closed
scottcha opened this issue Jun 1, 2017 · 1 comment

Comments

@scottcha
Copy link

scottcha commented Jun 1, 2017

Example as documented in the snowtel code:

params = StationHourlyDataIO(
    station='302:OR:SNTL',
    start_date='2014-07-01',
    end_date='2014-07-02',
)

for param in params:
    print(param.element_name)
    for row in param.data:
        print("   ", row.datetime, row.value, param.storedunitcd)

OUTPUT:

BATTERY

Stack Trace:
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-15-11de896be9bd> in <module>()
      7 for param in params:
      8     print(param.element_name)
----> 9     for row in param.data:
     10         print("   ", row.datetime, row.value, param.storedunitcd)

C:\Users\scott\Anaconda3\envs\python35\lib\site-packages\wq\io\base.py in __iter__(self)
    153     def __iter__(self):
    154         for item in self.data:
--> 155             uitem = self.usable_item(item)
    156             if uitem is None:
    157                 return

C:\Users\scott\Anaconda3\envs\python35\lib\site-packages\wq\io\mappers.py in usable_item(self, item)
    122 
    123     def usable_item(self, item):
--> 124         mapped = super(TupleMapper, self).usable_item(item)
    125         try:
    126             return self.tuple_prototype._replace(**mapped)

C:\Users\scott\Anaconda3\envs\python35\lib\site-packages\wq\io\mappers.py in usable_item(self, item)
     24     def usable_item(self, item):
     25         uitem = {}
---> 26         for key, val in item.items():
     27             field = self.map_field(key)
     28             value = self.map_value(field, val)

AttributeError: 'hourlyDataValue' object has no attribute 'items'

I tried looking in to figuring out how to resolve this in the code but I'm not familiar with wq or the design of the library.
Thanks!

@sheppard
Copy link
Member

Thanks, apparently the hourly class wasn't covered by a test case. It should now be working in master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants