회사에서 사용할 자동화 툴 ( excel + python)
언어/python2017. 11. 22. 17:57
#___________________________________________________
import openpyxl
import pprint
import operator
#___________________________________________________
# 엑셀파일 열기
wb = openpyxl.load_workbook('C:\\Users\\sleep\\Desktop\\s12.xlsx')
# 현재 Active Sheet 얻기
ws = wb.active
# ws = wb.get_sheet_by_name("Sheet1")
listValue = list()
test_dir = dict()
for r in ws.rows:
for i in range(2, 8):
if r[i].value != None:
listValue.append(r[i].value)
F_indx = 0
L_indx = 6
t_Key_list = list()
t_Val_list = list()
d_value = dict()
result = 1
step1_list = list()
while True:
step1_list.append(listValue[F_indx:L_indx])
F_indx = L_indx
L_indx += 6
if L_indx == len(listValue):
step1_list.append(listValue[F_indx:L_indx])
break
print (step1_list)
for i in range(0, len(step1_list), 2):
for j in range(6):
if step1_list[i][j] not in d_value.keys():
d_value[step1_list[i][j]] = step1_list[i+1][j]
else:
if d_value[step1_list[i][j]] != step1_list[i+1][j]:
print ("error")
print (d_value)
wb.close() #_________________ load excel end
sorted_key = sorted(d_value.items(), key=operator.itemgetter(0))
d_dic = dict(sorted_key)
print (d_dic)
'언어 > python' 카테고리의 다른 글
capche (0) | 2017.12.13 |
---|---|
크롤링 (0) | 2017.11.26 |
stu (0) | 2017.11.19 |
pe 세미 프로젝트 (0) | 2017.11.05 |
pe구조 => 엑셀 [파이썬] (0) | 2017.10.29 |