Example of simple EXCEL data statistics using python

Source: Internet
Author: User
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!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.