Introduction to Python office 3: xlrd operation worksheet

Time:2021-11-25

Worksheet

1 import xlrd
 2 
 3 # accept worksheet
 4 data=xlrd.open_workbook("data.xlsx")
 5 # query the opening status of the first worksheet
 6 print(data.sheet_loaded(0))
 7 # open all worksheets and output them as a list
 8 print(data.sheets())
 9 print(data.sheets()[0])
10 # get worksheet with index 0
11 print(data.sheet_by_index(0))
12 # get a worksheet with a specific name and recognize case
13 print(data.sheet_by_name("Sheet1"))
14 # output the names of all worksheets
15 print(data.sheet_names())
16 # get the number of all worksheets
17 print(data.nsheets)

Output results

1 D:\Project_new\pycharmproject\venv\Scripts\python.exe D:/Project_new/pycharmproject/index.py
2 True
3 []
4 
5 
6 
7 ['Sheet1']
8 1
9 18

 

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 […]