BennyThadikaran / eod2

A fully automated script to download and update NSE EOD Historical stock, index and delivery data with added features
GNU General Public License v3.0
68 stars 24 forks source link

Data import failed #136

Closed Prady04 closed 5 months ago

Prady04 commented 5 months ago

Error log CRITICAL: Unhandled exception Traceback (most recent call last): File "D:\python\eod2-main\src\init.py", line 58, in if not defs.dates.nextDate(): ^^^^^^^^^^^^^^^^^^^^^ File "D:\python\eod2-main\src\defs\defs.py", line 95, in nextDate t_str = local_time.strftime("%-I:%M%p") # 7:00PM ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ValueError: Invalid format string CRITICAL: Unhandled exception Traceback (most recent call last): File "D:\python\eod2-main\src\init.py", line 58, in if not defs.dates.nextDate(): ^^^^^^^^^^^^^^^^^^^^^ File "D:\python\eod2-main\src\defs\defs.py", line 95, in nextDate t_str = local_time.strftime("%-I:%M%p") # 7:00PM ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

BennyThadikaran commented 5 months ago

I isolated the code below. It is working on Linux. I havent encountered this error on EOD2. I'll run it on Windows and get back.

Can you confirm your Python version?

from datetime import datetime
from zoneinfo import ZoneInfo
import tzlocal

tz_local = tzlocal.get_localzone()
tz_IN = ZoneInfo("Asia/Kolkata")

curTime = datetime.now(tz_IN)

local_time = curTime.replace(hour=19, minute=0).astimezone(tz_local)

t_str = local_time.strftime("%-I:%M%p")

print(t_str)
BennyThadikaran commented 5 months ago

I reproduced the error in Windows. Seems like a Windows specific issue. The - character to removed the leading 0 is not recognized in Python on Windows.

I will post a fix for this. It would seem like all my future updates need to be tested on Windows first.

Thanks @Prady04

BennyThadikaran commented 5 months ago

I have fixed the issue in all branches

BennyThadikaran commented 5 months ago

Tested on Windows and all working well. Closing this issue.