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,230 points
964 views

1 answer to this question.

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,150 points

Related Questions In Selenium

0 votes
1 answer
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,110 points
5,498 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,110 points
1,147 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,150 points
1,247 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,150 points
1,003 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,150 points
749 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,150 points
2,804 views