The following small series will bring you an example of using python to implement simple EXCEL data statistics. I think this is quite good. now I will share it with you and give you a reference. Let's take a look at the task together with the editor:
Use the simple python time statistical task-count the number of male and female persons respectively.
Materials used: xlrd its function-reading excel table data
Code:
Import xlrdworkbook = xlrd.open_workbook('demo.xlsx') # Open the excel data table SheetList = workbook. sheet_names () # read the workbook to the list. SheetName = SheetList [0] # read the name of the first workbook. Sheet1 = workbook. sheet_by_index (0) # The E-table index starts from 0. Sheet1 = workbook. sheet_by_name (SheetName) # instantiate the workbook object m = 0f = 0 for I in range (Sheet1.nrows): rows = Sheet1.row _ values (I) if rows [2] = 'male ': m + = 1 elif rows [2] = 'female': f + = 1 print ('male: ', m, 'female:', f)
The above example of using python to implement simple EXCEL data statistics is all the content that I have shared with you. I hope to give you a reference and support for PHP.
For more articles about examples of using python to implement simple EXCEL data statistics, please follow the PHP Chinese network!