Ошибка в роботе с csv файлами в боте

fell

Новичок
Пользователь
Сен 28, 2020
1
0
1
Код ошибки
Traceback (most recent call last):
File "w23.py", line 48, in <module>
if now in str(df['timing']):
File "C:\Users\Lenovo\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pandas\core\frame.py", line 2902, in __getitem__
indexer = self.columns.get_loc(key)
File "C:\Users\Lenovo\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pandas\core\indexes\base.py", line 2893, in get_loc
raise KeyError(key) from err
KeyError: 'timing'
Сам Код
import subprocess
import pyautogui
import time
import pandas as pd
from datetime import datetime

def sign_in(meetingid, pswd):
#Opens up the zoom app
subprocess.call(["C:/Users/Lenovo/AppData/Roaming/Zoom/bin/Zoom.exe"])

time.sleep(10)

#clicks the join button
join_btn = pyautogui.locateCenterOnScreen('join_button.png')
pyautogui.moveTo(join_btn)
pyautogui.click()

# Type the meeting ID
meeting_id_btn = pyautogui.locateCenterOnScreen('meeting_id_button.png')
pyautogui.moveTo(meeting_id_btn)
pyautogui.click()
pyautogui.write(meetingid)

# Disables both the camera and the mic
media_btn = pyautogui.locateAllOnScreen('media_btn.png')
for btn in media_btn:
pyautogui.moveTo(btn)
pyautogui.click()
time.sleep(2)

# Hits the join button
join_btn = pyautogui.locateCenterOnScreen('join_btn.png')
pyautogui.moveTo(join_btn)
pyautogui.click()

time.sleep(5)
#Types the password and hits enter
meeting_pswd_btn = pyautogui.locateCenterOnScreen('meeting_pswd.png')
pyautogui.moveTo(meeting_pswd_btn)
pyautogui.click()
pyautogui.write(pswd)
pyautogui.press('enter')

df = pd.read_csv('timings.csv')
while True:
# checking of the current time exists in our csv file
now = datetime.now().strftime("%H:%M")
if now in str(df['timing']):

row = df.loc[df['timing'] == now]
m_id = str(row.iloc[0,1])
m_pswd = str(row.iloc[0,2])

sign_in(m_id, m_pswd)
time.sleep(40)
print('signed in')
что не так ?
 

regnor

Модератор
Команда форума
Модератор
Июл 7, 2020
2 625
469
83
Попробуйте оформить код в теги code, так ничего не понятно
 

Форум IT Специалистов