인프런 - 강의/김대리님 이게 바로 업무자동화입니다

4 - 회사별로 행 끊어내기

----___<<<<< 2020. 3. 30. 16:35

from openpyxl import load_workbook

read_wb = load_workbook('./test.xlsx', data_only=True)
read_ws = read_wb.active

list1 = []

row = 70

for i in range(2, row) :

    list1.append(read_ws.cell(i, 2).value)

print(list1)

list2 = set(list1)

print(list2)

list3 = list(filter(None, list2))

print(list3)

for i in list3 :

    current_company = i

    temp_list = []

    for j in range(2, row) :
        # j = 2,3,4,5,6,7 --

        if current_company == read_ws.cell(j, 2).value :
            temp_list.append(j)

    print(current_company)
    print(temp_list)