opendoor-labs / rets

RETS Python 3 Client
MIT License
89 stars 43 forks source link

ValueError: unconverted data remains: T00:00:00.000 #31

Closed aviivgi closed 6 years ago

aviivgi commented 6 years ago

Executing the following line:

search_result = resource_class.search(query='(StatusChangeTimestamp=2018-09-04-2018-09-05)')

Generates the following error:

WARNING:root:UnexpectedError: <class 'ValueError'>
Traceback (most recent call last):
  File "rets_downloader_property_data_v3.0.py", line 179, in <module>
    search_result = resource_class.search(query='(StatusChangeTimestamp=2018-09-04-2018-09-05)')
  File "/Users/bigoper/GitHub/idx2.0/com.idx20.downloader.rets.python/rets/client/resource_class.py", line 66, in search
    rows = decoder.decode(result.data)
  File "/Users/bigoper/GitHub/idx2.0/com.idx20.downloader.rets.python/rets/client/decoder.py", line 34, in decode
    for row in rows)
  File "/Users/bigoper/GitHub/idx2.0/com.idx20.downloader.rets.python/rets/client/decoder.py", line 34, in <genexpr>
    for row in rows)
  File "/Users/bigoper/GitHub/idx2.0/com.idx20.downloader.rets.python/rets/client/decoder.py", line 33, in <genexpr>
    return tuple(OrderedDict((field, decode_field(field, value)) for field, value in row.items())
  File "/Users/bigoper/GitHub/idx2.0/com.idx20.downloader.rets.python/rets/client/decoder.py", line 31, in decode_field
    return decoders[field](value)
  File "/Users/bigoper/GitHub/idx2.0/com.idx20.downloader.rets.python/rets/client/decoder.py", line 96, in <lambda>
    'Date': lambda value: datetime.strptime(value, '%Y-%m-%d'),
  File "/Users/bigoper/anaconda3/lib/python3.6/_strptime.py", line 565, in _strptime_datetime
    tt, fraction = _strptime(data_string, format)
  File "/Users/bigoper/anaconda3/lib/python3.6/_strptime.py", line 365, in _strptime
    data_string[found.end():])
ValueError: unconverted data remains: T00:00:00.000
  1. I did not change any line in my code
  2. It stopped working few weeks ago

Thanks!

martinxsliu commented 6 years ago

@aviivgi It appears that the MLS you're querying is advertising some field as having type Date but is actually sending full date time strings. Can you confirm this?

The Date parser expects values in the format 2018-09-05 in accordance with the RETS standard, but based on your exception message you're receiving 2018-09-05T00:00:00.000. We could do something like strip off the extra characters, or just try to parse and return the date time.

aviivgi commented 6 years ago

@martinxsliu Thank you so much, you're on spot! They've changed the 'datetime' to a 'timestamp'.