mariostoev/finviz

ValueError when converting date

Closed this issue · 2 comments

My program has suddenly stopped working without me changing anything and throws the following error:

finviz\main_func.py: line 110

parsed_timestamp = datetime.strptime(raw_timestamp, "%b-%d-%y %I:%M%p")

ValueError: time data '\r\n Aug-11-23 07:41AM\r\n ' does not match format '%b-%d-%y %I:%M%p'

It appears to be adding whitespace characters both before and after the date - anyone else experiencing this?

just add this line :
raw_timestamp = str(raw_timestamp).strip()
after line 110 in main_func.py:

    for row in rows:
        raw_timestamp = row.xpath("./td")[0].xpath("text()")[0][0:-2]

to be as shown :

for row in rows:
     raw_timestamp = row.xpath("./td")[0].xpath("text()")[0][0:-2]
     raw_timestamp = str(raw_timestamp).strip()

just add this line : raw_timestamp = str(raw_timestamp).strip() after line 110 in main_func.py:

    for row in rows:
        raw_timestamp = row.xpath("./td")[0].xpath("text()")[0][0:-2]

to be as shown :

for row in rows:
     raw_timestamp = row.xpath("./td")[0].xpath("text()")[0][0:-2]
     raw_timestamp = str(raw_timestamp).strip()

Thank you! This fixed it - I will mark this as closed now :).