Created
November 9, 2018 11:26
-
-
Save marceloandriolli/b286d2b482a772e2dc57a41a9ef93a00 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from openpyxl import load_workbook | |
wb = load_workbook(filename='ic5.xlsx', read_only=True) | |
ws = wb.get_sheet_by_name('Sheet1') | |
def iter_rows(ws): | |
for row in ws.iter_rows(): | |
yield[cell.value for cell in row] | |
l = list(iter_rows(ws)) | |
iC3 = 0 | |
iC5 = 0 | |
iC7 = 0 | |
import json | |
ret = [] | |
for t in l: | |
print(t[0]) | |
if t[0] == 'IC3' or t[0] == 'iC3': | |
device = {'model': 'iC3', 'id': t[3], 'sn': t[5]} | |
ret.append(device) | |
iC3 += 1 | |
continue | |
if t[0] == 'IC5' or t[0] == 'iC5': | |
device = {'model': 'iC5', 'id': t[1], 'sn': t[5]} | |
ret.append(device) | |
iC5 += 1 | |
continue | |
if t[0] == 'IC7' or t[0] == 'iC7': | |
device = {'model': 'iC7', 'id': t[1], 'sn': t[5]} | |
ret.append(device) | |
iC7 += 1 | |
continue | |
print(iC5) | |
print(iC3) | |
print(iC7) | |
# file = open(f'order_31.json', 'w') | |
# file.write(str(ret)) | |
# file.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment