python-- read Excel content

import xlrd

def extract(inpath):
    data = xlrd.open_workbook(inpath, encoding_override='utf-8')
    Table = data.sheets () [0]   # of the selected table 
    nrows = table.nrows   # acquires the line number 
    ncols = table.ncols   # Get the column number

    for I in Range (. 1, nrows):   # 0 acts header 
        AllData = table.row_values (I)   # cyclic output excel table each row, i.e., all data 
        Result = AllData [. 6]   # removed in column 7 of table data 
        Print (the Result)

the inpath = ' ./test.xls '   # Excel file path where the 
extract (inpath)

Guess you like

Origin www.cnblogs.com/lutt/p/12207857.html