0

I'm attempting to loop through lines of an excel file and write the data in a web application. I'm using a mixture of openpyxl to get the excel data and pyautogui to click and type in the web application. However, when I get to the point to enter the data:

c=Sheet.cell(row=i,column=7).value
    pyautogui.typewrite(c)

I get an error "for c in message: TypeError: 'int' object is not iterable". Is there any way I can get around this? It sounds like pyautogui can only type exact strings, not read from variables?

import openpyxl
import pyautogui
import time
wb = openpyxl.load_workbook('H:\\Python Transfer.xlsx')
type (wb)
wb.get_sheet_names()
Sheet = wb.get_sheet_by_name('Sheet1')
lastRow = Sheet.max_row
for i in range(2,lastRow + 1):
    #print(Sheet.cell(row=i,column=7).value)
    pyautogui.click(1356,134)
    time.sleep(5)
    c=Sheet.cell(row=i,column=7).value
    pyautogui.typewrite(c)
    time.sleep(2)
    pyautogui.click(1528,135)

Thank you!!

2
  • 2
    I assume pyaugogui sends keystrokes one character (or key) at a time, so maybe try converting c to a string; pyautogui.typewrite(str(c)) Commented Aug 14, 2017 at 16:59
  • Thank you!! This worked! Commented Aug 14, 2017 at 17:01

1 Answer 1

2

typewrite() takes a string, so convert c to a string:

pyautogui.typewrite(str(c))

See the docs: http://pyautogui.readthedocs.io/en/latest/keyboard.html

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.