Python beginner--to achieve the sorting of reading data in Excel (improved algorithm)

Source: Internet
Author: User

#coding: Gbkimport xlrdimport xlwtimport timedef read_excel (c):     if  c==0:        print  "Usage rankings:"          for i in range (1,sheet.nrows):             lie[sheet.cell (i,c). Value.encode (' GBK ')] = sheet.cell (i,c+1). value* ( 100/50)             i = i+1         newlie = sorted (Lie.iteritems (), key = lambda d:d[ 1],reverse = true)         for i in range (0, Len (Newlie)):             print newlie[i][0]+ " : "+str (newlie[i][1]) +" min, " ,            i  = i+1        print  "\ n"         return     print sheet.cell (0,c). Value.encode (' GBK ') + ":"     for i in  range (1,sheet.nrows):         lie[sheet.cell (i,0). Value.encode (' GBK ')] = sheet.cell (i,c). value        i = i+1     newlie = sorted (Lie.iteritems (), Key = lambda d:d[1],reverse  = true)     for i in range (0,len (Newlie)):         print newlie[i][0]+ ":" + "%.1f"  % (newlie[i][1]) + "points,"  ,         i = i+1    print  "\ n" start =  Time.time () if __name__ ==  ' __main__ ':     url = r ' D:\python  Case\0.excel Score Sort-2015.12.18\fenshu.xlsx '     workbook = xlrd.open_workbook (URL, ' RB ')      sheet_name = workbook.sheet_names () [1]    sheet = workbook.sheet _by_index (1)     sheet = workbook.sheet_by_name (' Sheet1 ')      lie = {}    print  '-' *20    for c in  Range (0,5):         read_excel (c)     c =  Time.time ()  - start    print (' program run time:%0.2f '% (c))


This article is from the "Ahua" blog, make sure to keep this source http://songzaihua.blog.51cto.com/321961/1727722

Python beginner--to achieve the sorting of reading data in Excel (improved algorithm)

Related Article

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.