Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import openpyxl
- import call
- book = openpyxl.load_workbook('data.xlsx')
- sheet = book.active
- data = []
- for ro in range(2,6):
- for co in range(1,8):
- #print('co =%d ro =%d' % (co, ro))
- a3 = sheet.cell(row=ro, column=co)
- data.append(a3.value)
- print(data)
- #รับค่าจาก excel และเปลี่ยนชนิดตัวแปร
- v1, v2, P, x1o, x2o, x3o, xgo = data
- x1o = x1o.replace('', '')
- x2o = x2o.replace('', '')
- x3o = x3o.replace('', '')
- xgo = xgo.replace('', '')
- x1 = complex(x1o)
- x2 = complex(x2o)
- x3 = complex(x3o)
- xg = complex(xgo)
- # ฟังชั่นการคำนวณจากฟอร์แทรน
- x12 = call.xt1(x1, x2, x3)
- Vcurrent = call.vc(v1, v2, P, x12) # <class 'tuple'>((0.9+0.3j), (1+0.1j))
- Voltage = Vcurrent[0]
- Curr = Vcurrent[1]
- PmEg = call.pm(Voltage, v2, xg, x12, Curr) # <class 'tuple'>
- Pemax = PmEg[0]
- Eg = PmEg[1]
- print('Voltage = %.4f + %.4fi' % (Voltage.real, Voltage.imag))
- print('current = %.4f + %.4fi' % (Curr.real, Curr.imag))
- print('Eg = %.4f + %.4fi' % (Eg.real, Eg.imag))
- print('Pemax = %.4f ' % Pemax)
- data = []
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement