Python reads Excel, uses Google to search Python Excel, clicks the first result http://www.python-excel.org/, and can work with Excel across platforms.
Follow the documentation step-by-step to install three packages:
- XLRD (for reading Excel);
- XLWT (for writing Excel);
- Xlutils (Toolbox for working with Excel)
1 fromXlrdImportOpen_workbook2 ImportRe3 4 #Create a generator to read sheet, generate each row of data sequentially, Row_count to specify how many rows to read, Col_count specify how many columns to read5 defReadsheet (S, Row_count=-1, col_cout=-1):#6 #How many lines does Sheet have?7nrows =s.nrows8 #Sheet How many columns are there?9Ncols =S.ncolsTenRow_count = (row_countifRow_count > 0Elsenrows) OneCol_count = (col_countifCol_count > 0Elsencols) ARow_index =0 - whileRow_index <Row_count: - yield[S.cell (Row_index, col). Value forColinchxrange (col_count)] theRow_index + = 1 - -WB = Open_workbook ('Simple.xls')#Open Excel File - #Read all the sheet in Excel + forSinchwb.sheets (): - forRowinchReadsheet (S, 10, 10):#Read Only the first 10 rows of each sheet, the first 10 columns (of course you want to make sure that your data is more than 10 rows, and the extra 10 columns) + PrintRow
Very simple, mainly used in Xlrd four features Open_workbook, Wb.sheets (), s.nrows-(number of rows), S.ncols-(Number of columns), S.cell (Row, col). value-(Gets the value at the specified unit).
These functions are sufficient for handling general read operations.
Python reads excle file data