← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #263498]: How to open an saved excel file

 

Question #263498 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/263498

    Status: Open => Answered

aidma proposed the following answer:
I'm not quite sure what's being asked here...

Do you want to (1) use Sikuli to open the file within the Excel
application, or (2) use Sikuli to access data within an Excel file
(without ever opening the Excel Application)?

If (1), then write a Sikuli script to open it. There are many ways to do
this. A simple script that navigates to the icon, and then
doubleClick()s it would suffice. Sikuli scripts have control over your
mouse and keyboard. So if you can open the file with your mouse and
keyboard then, in theory, so can Sikuli.

If (2), then import a python library for handling Excel files. Remember: Sikuli scripts are written in the Python language. The Sikuli functions are great at doing visual things (moving your mouse, clicking, typing, etc.), but they aren't really made for accessing data from a file. If you want to grab data from an excel file in your script, I would suggest the following:
 - Save the excel file as a .csv 
 - Create a Sikuli Script with the code:
_____CODE START_____
import csv

with open('INSERT-PATH-TO-CSV-FILE-HERE', 'rb') as csvfile:
    reader = csv.reader(csvfile, delimiter=',')
    data = [row for row in reader] #saves data to a 2D list

print data #prints all data
print data[0] #prints the data from the first row
print data[0][0] #prints the data from the first cell in the first row
_____CODE END_____
 - You now have a script that saves the data from the CSV file in a 2 dimensional list named data

-- 
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.