Read data from excel sheet in python

0 votes

How to Read data from excel sheet in python. how to read data from excel sheet in selenium python framework?

Below is my code:

def getcell(rows,cols):

table=list()

record=list()

for x in range(rows):

    for y in range(cols):

        record.append(SheetName.cell(x,y).value)    

        table.append(record)

        record=[]

        rows=rows+1

return table;

print(table)
Jun 28, 2018 in Selenium by Martin
• 4,210 points
414 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

Try to use xrld. A python module used to read MS excel sheets.

This example will help you:

import xlrd

book = xlrd.open_workbook("myfile.xls")

print "The number of worksheets is", book.nsheets

print "Worksheet name(s):", book.sheet_names()

sh = book.sheet_by_index(0)

print sh.name, sh.nrows, sh.ncols

print "Cell D30 is", sh.cell_value(rowx=29, colx=3)

for rx in range(sh.nrows):

    print sh.row(rx)

answered Jun 28, 2018 by Samarpit
• 5,130 points

Related Questions In Selenium

0 votes
1 answer
0 votes
1 answer

Reading data from Excel in my Selenium test

Log4j problems are usually thrown because of ...READ MORE

answered Apr 6, 2018 in Selenium by nsv999
• 5,050 points
2,243 views
+2 votes
2 answers

How can I press ENTER key with the execute_script in selenium python?

The below code containing Keys.ENTER might just ...READ MORE

answered Mar 27, 2018 in Selenium by nsv999
• 5,050 points
4,433 views
0 votes
2 answers

Unable to Click on an Element in Selenium (Python) even after finding it.

Here, I give you working script which ...READ MORE

answered Sep 19, 2018 in Selenium by Priyaj
• 56,140 points
5,081 views
0 votes
1 answer

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,050 points
131 views
0 votes
1 answer
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,130 points
519 views
0 votes
1 answer

How to use such xpath to find web elements

It's much simpler to use: #MyDiv123 > div.super or ...READ MORE

answered Jun 14, 2018 in Selenium by Samarpit
• 5,130 points
119 views
0 votes
1 answer

Error in for loop to fetch data from excel in selenium

You are closing theFileInputStream inside the for-loop. ...READ MORE

answered Jun 20, 2018 in Selenium by Samarpit
• 5,130 points
165 views
0 votes
1 answer

How to handle notifications in Python with Selenium (Chrome WebDriver)

Below will help you: You can disable the ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,130 points
1,536 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.