Python Extracts analytic tabular data

Source: Internet
Author: User

#/bin/python3.4
#-*-Coding:utf-8-*-

Import xlrd

def open_excel (file= "File.xls"):
Try
data = Xlrd.open_workbook (file)
Return data
Except Exception:
Print ("Please check excel!")

# get Excel Tabular data by index
# Parameters: Table:excel file path Colnameindex: Table header column name row, By_index: Table index
def excel_table_byindex (file= "File.xls", Colindex=0, Rowindex=0, byindex=0):
data = Open_excel (file)
Table = Data.sheets () [Byindex]
nrows = Table.nrows
Ncols = Table.ncols

RowName = Table.row_values (colindex) #获取某一行数据
ColName = Table.col_values (rowindex) #获取某一列数据

Return colname

# Get project group membership information
def get_project_info (file= "File.xls", byindex=0):
data = Open_excel (file)
Table = Data.sheets () [Byindex]

nrows = Table.nrows
Ncols = Table.ncols

ProjectName = ["Icotos", "Cgsl", "Cgel", "tsp", "VP", "Management team"]

Ictos_colnames = table.col_values (0) # A column of data
Cgsl_colnames = Table.col_values (2)
Cgel_colnames = Table.col_values (4)
Tsp_colnames = table.col_values (6)
Vp_colnames = table.col_values (8)
Manage_colnames = Table.col_values (10)

Ictos_memset = ictos_colnames[3:44]
Cgsl_memset = cgsl_colnames[3:29]
Cgel_memset = cgsl_colnames[3:36]
Tsp_memset = cgel_colnames[3:25]
Vp_memset = vp_colnames[3:50]
Manage_set = Manage_colnames[3:13]

Projectset = [Ictos_memset, Cgsl_memset, Cgel_memset, Tsp_memset, Vp_memset, Manage_set]

For I in range (len (projectname)):
#print (Projectname[i] + "project group member" +STR (Projectset[i]) + "\ n total:%d"%len (Projectset[i]))
Pass

Return Projectset


def main ():
File2 = "/media/a/work/ci work/project group material/project group member list. xlsx"
Data2 = Get_project_info (file2)
Print (DATA2)

file1= "/media/a/work/ci work/9 months/Employee submission statistics Export 20170930170546.xls"
Data1 = Excel_table_byindex (File1, 4, 4, 0)
Commit_info = Data1[1:len (data1)]
Print ("Total commit information%d"%len (commit_info) + "\ n" + str (commit_info))

result= {"Ictos": 0, "CGSL": 0, "Cgel": 0, "tsp": 0, "VP": 0, "Manager": 0}
For item in Set (Commit_info):
Print ("The%s has found%d"% (item, Commit_info.count (item)))
If item in Data2[0]:
result[' Ictos '] + = Commit_info.count (item)
If item in DATA2[1]:
result[' CGSL '] + = Commit_info.count (item)
If item in DATA2[2]:
result[' Cgel '] + = Commit_info.count (item)
If item in DATA2[3]:
result[' tsp '] + = Commit_info.count (item)
If item in DATA2[4]:
result[' VP '] + = Commit_info.count (item)
If item in DATA2[5]:
result[' manager '] + = Commit_info.count (item)

For item in Result.items ():
Print (item)

if __name__ = = "__main__":
Main ()

Python Extracts analytic tabular data

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.