Advertisement
Rujeerat

Untitled

Nov 2nd, 2019
269
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.22 KB | None | 0 0
  1. import openpyxl
  2. import call
  3. book = openpyxl.load_workbook('data.xlsx')
  4. sheet = book.active
  5. data = []
  6. for ro in range(2,6):
  7.     for co in range(1,8):
  8.         #print('co =%d ro =%d' % (co, ro))
  9.         a3 = sheet.cell(row=ro, column=co)
  10.         data.append(a3.value)
  11.     print(data)
  12.  
  13.     #รับค่าจาก excel และเปลี่ยนชนิดตัวแปร
  14.     v1, v2, P, x1o, x2o, x3o, xgo = data
  15.     x1o = x1o.replace('', '')
  16.     x2o = x2o.replace('', '')
  17.     x3o = x3o.replace('', '')
  18.     xgo = xgo.replace('', '')
  19.     x1 = complex(x1o)
  20.     x2 = complex(x2o)
  21.     x3 = complex(x3o)
  22.     xg = complex(xgo)
  23.  
  24.     # ฟังชั่นการคำนวณจากฟอร์แทรน
  25.     x12 = call.xt1(x1, x2, x3)
  26.     Vcurrent = call.vc(v1, v2, P, x12)  # <class 'tuple'>((0.9+0.3j), (1+0.1j))
  27.     Voltage = Vcurrent[0]
  28.     Curr = Vcurrent[1]
  29.     PmEg = call.pm(Voltage, v2, xg, x12, Curr)  # <class 'tuple'>
  30.     Pemax = PmEg[0]
  31.     Eg = PmEg[1]
  32.     print('Voltage = %.4f + %.4fi' % (Voltage.real, Voltage.imag))
  33.     print('current = %.4f + %.4fi' % (Curr.real, Curr.imag))
  34.     print('Eg = %.4f + %.4fi' % (Eg.real, Eg.imag))
  35.     print('Pemax = %.4f ' % Pemax)
  36.     data = []
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement