Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import openpyxl
- import numpy as np
- import time
- Book = openpyxl.Workbook()
- sheetBook = Book.active
- bookRoster = openpyxl.open('inAll.xlsx')
- sheetRoster = bookRoster.active
- def ConsTop():
- print("Реультат будет записан в фаил in.xlsx")
- print("IN set value - Acetylene C2H2 / Methane CH4 / Ethylene C2H4: ")
- print("OUT defect type - Разр низк энерг(D1) / Разр высок энерг(D2) / Tепл поврежд и разр (DT)")
- print("Тепл поврежд (Т1)<300 / Тепл поврежд (Т2)>300 / Тепл поврежд (Т3)>700 / Частич разр (PD)")
- ConsTop()
- numBase = int(sheetRoster[4][8].value+1)
- print(numBase)
- ############
- setName = ["H2", "CH4", "C2H6", "C2H4", "C2H2"]
- def PpmToPr(GasPPM):
- arr1 = np.divide(GasPPM, max(GasPPM))
- return list(arr1)
- def orderPoint(GasPPM):
- copyAr = GasPPM
- aaa = list(zip(copyAr, [0,1,2,3,4]))
- aaa.sort(reverse=True)
- a,b = zip(*aaa)
- return list(b)
- def chekD(T2,setVal):
- for item in T2:
- if (item == setVal):
- return 1
- return 0
- def TypeID(setGaz,setVal):
- i=0
- for item in setGaz:
- if chekD(item,setVal):
- return i
- i += 1
- return -1
- def outD(setVal):
- D1 = [[0, 1, 4, 3, 2]]; PDn = [[0, 1, 2, 3, 4]]; Iskr = [[0, 3, 1, 4, 2]]; Duga = [[0, 4, 3, 1, 2], [4, 0, 1, 3, 2]];
- T2 = [[1, 3, 0, 2, 4],[1, 0, 3, 2, 4],[1, 3, 2, 0, 4]]; T2toPD = [[1, 0, 2, 3, 4]];
- T3 = [[3, 1, 4, 0, 2],[3, 2, 1, 4, 0],[3, 2, 1, 0, 4]]; T3toDuga = [[3, 1, 0, 4, 2]];
- setGaz = [D1, PDn, Iskr, Duga, T2, T2toPD, T3, T3toDuga]
- setName2 = ['D1', 'PDn', 'Iskr', 'Duga', 'T2', 'T2toPD', 'T3', 'T3toDuga']
- Name = TypeID(setGaz,setVal)
- if Name == -1:
- return "None"
- else:
- #return setName2[0]
- return setName2[TypeID(setGaz,setVal)]
- ###############
- # чтение
- def GetExell(numBase):
- ArExell = []
- for row in range(5,numBase):
- try:
- H2 = int(sheetRoster[row][0].value) #
- CH4 = int(sheetRoster[row][1].value) #
- C2H2 = int(sheetRoster[row][2].value) #
- C2H4 = int(sheetRoster[row][3].value) #
- C2H6 = int(sheetRoster[row][4].value) #
- CO = int(sheetRoster[row][5].value) #
- CO2 = int(sheetRoster[row][6].value) #
- except:
- print("Something went wrong")
- ArExell.append("None")
- continue
- GasPPM = [H2, CH4, C2H6, C2H4, C2H2]
- setName = ["H2", "CH4", "C2H6", "C2H4", "C2H2"]
- ArExell.append(outD(orderPoint(GasPPM)))
- return ArExell
- # Записьы
- i=1
- for item in GetExell(numBase):
- sheetRoster.cell(i+4,10).value = str(item)
- print(item)
- i+=1
- bookRoster.save("OUT_RDgrafExel.xlsx")
- print("ГОТОВО")
- Book.close()
- bookRoster.close()
- time.sleep(15)
Add Comment
Please, Sign In to add comment