Introduction to Python office 4: xlrd operating excel lines

Time:2021-11-24

Operating excel lines

1 # get operation line through index
 2 sheet=data.sheet_by_index(0)
 3 # get the number of valid rows under the current sheet
 4 print(sheet.nrows)
 5 # get the specific data of a row. It is a list composed of cell objects in the row. The preceding indicates the data type
 6 print(sheet.row(0))
 7 # get the data type of a row
 8 print(sheet.row_types(0))
 9 # get the value pair of one cell in a row
10 print(sheet.row(3)[3])
11 # just get the value of the cell
12 print(sheet.row(3)[3].value)
13 # get a row of values
14 print(sheet.row_values(3))
15 # get the length of a line
16 print(sheet.row_len(3))

Operation results

1 13
2 [text: 'column 1', text: 'code', text: 'cost', text: 'total amount', text: 'platform', text: 'profit', text: 'category']
3 array('B', [1, 1, 1, 1, 1, 1, 1])
4 number:16866.86
5 16866.86
6 ['wechat change', 'change', 16836.48, 16866.86, 'wechat change', 30.38000000000102, 'change']
7 7

 

Recommended Today

Apache sqoop

Source: dark horse big data 1.png From the standpoint of Apache, data flow can be divided into data import and export: Import: data import. RDBMS—–>Hadoop Export: data export. Hadoop—->RDBMS 1.2 sqoop installation The prerequisite for installing sqoop is that you already have a Java and Hadoop environment. Latest stable version: 1.4.6 Download the sqoop installation […]