Unable to open excel worksheet with open_workbook command in Sikuli

Asked by Ruqsar Jahan on 2017-10-16

I have performed the below steps before I could actually used the open_workbook:

1. downloaded package xlrd and unzipped it in the desired location

2. imported it by using:
dir_xlrd = "C:\\Users\\RJ043486\\SIKULI\\Lib\\xlrd\\dist\\xlrd-1.1.0\\xlrd"
if not dir_xlrd in sys.path: sys.path.append(dir_xlrd)
import xlrd

book = xlrd.open_workbook(r'C:\UserNameTEST.xls')

My problem is, even though I'm giving the exact location where I have saved the excel sheet, it still throws me error:
[error] script [ WorkBench ] stopped with error in line 7
[error] IOError ( (2, 'No such file or directory', 'C:\\UserNameTEST.xls') )
[error] --- Traceback --- error source first line: module ( function ) statement 394: __init__ ( open_workbook ) IOError: (2, 'No such file or directory', 'C:\\UserNameTEST.xls')
[error] --- Traceback --- end --------------

I have even tried:
book = xlrd.open_workbook(C:\\UserNameTEST.xls)

it gave me the same error too.

Please help me with this.

Question information

Language:
English Edit question
Status:
Answered
For:
Sikuli Edit question
Assignee:
No assignee Edit question
Last query:
2017-10-16
Last reply:
2017-10-16
Ruqsar Jahan (ruqsar.jahan) said : #1

I had downloaded: xlrd-1.1.0.tar.gz which did not work, later I downloaded xlrd-0.7.9.tar.gz.. this as well was of no help.

RaiMan (raimund-hocke) said : #2

When using SikuliX 1.1.0+, no need to download anything - xlrd is already bundled and you only need
import xlrd

Try to store your XLS into a folder in your user home. The problem might be, that for some reason the root (c:\) does not work.

Ruqsar Jahan (ruqsar.jahan) said : #3

Thank you for your response.

I have only C Drive configured in laptop, since it is given by my company.
I had tried storing the excel in every possible location, including the SIKULI Folder itself but it did not work.

When you say user home, are you indicating the 'Desktop' or the D:/ drive?
I'm asking this because 'Desktop' would always be a part of C:/.

I did store it in the below location as well it got the same error.
book = xlrd.open_workbook(r'C:\Users\RJ043486\Excels\UserNameTEST.xls')

Ruqsar Jahan (ruqsar.jahan) said : #4

FYI-
I have SikulixIDE 1.1.1

RaiMan (raimund-hocke) said : #5

ok, I will check later on my Win7-64

Ruqsar Jahan (ruqsar.jahan) said : #6

Sure, awaiting reply.

RaiMan (raimund-hocke) said : #7

tested with SikuliX 1.1.1 on Win7-64 using the bundled module xlrd

with this script:
import xlrd
sheet = r'C:\Users\RaimFred\Desktop\test.xls'
book = xlrd.open_workbook(sheet)
#print dir(book) # to see possible methods
print book.sheet_names()
# prints: [u'Tabelle1']

... as you can see: works as expected.

so you have to check your setup and filenames

Can you help with this problem?

Provide an answer of your own, or ask Ruqsar Jahan for more information if necessary.

To post a message you must log in.