-
Notifications
You must be signed in to change notification settings - Fork 9
/
readExcel.py
35 lines (33 loc) · 971 Bytes
/
readExcel.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#! python3
#readExcel.py
#
#Author : qmeng
#MailTo : [email protected]
#QQ : 1163306125
#Blog : http:https://blog.csdn.net/Mq_Go/
#Create : 2018-02-010
#Version: 1.0
#
import openpyxl,pprint,os
print('Opening workbook...')
wb = openpyxl.load_workbook('2017.xlsx')
sheet = wb.get_sheet_by_name('Sheet0')
Data = {}
print('Reading rows...')
for row in range(3,sheet.max_row+1):
Num = sheet['B'+str(row)].value
Name = sheet['E'+str(row)].value
sProject = sheet['F'+str(row)].value
eProject = sheet['G'+str(row)].value
#填充数据结构
#Data.setdefault(Num,{Name:'',sProject:'',eProject:''})
Data[Num] = {'Name':Name,'sProject':sProject,'eProject':eProject}
#print(Name + ' 同学信息加载完毕...')
print('Writing results...')
File = open('abcdef.py','w')
File.write('allData = ' + pprint.pformat(Data))
File.close()
print('Done...')
#import abcdef
#>>> abcdef.allData['2017000349']
#{'Name': '18834198699', 'eProject': '9/933', 'sProject': 4.28}