Ask Your Question
0

Help update data in PSSE by Python 2.7 get data from excel file.

asked 2020-05-06 20:28:47 -0500

ngoclq.evncpc gravatar image

updated 2020-05-07 03:37:37 -0500

perolofl gravatar image

Hi all I want to update data of Bus in PSSE by Python 2.7, get data from excel. My code:

import os, sys
PYTHONPATH = r'C:\Program Files (x86)\PTI\PSSE33\PSSBIN'
sys.path.append(PYTHONPATH)
os.environ['PATH'] += ';' + PYTHONPATH
import psspy
psspy.throwPsseExceptions = True
import redirect
redirect.psse2py()
psspy.psseinit(1000)
psspy.case(r'C:\Users\ngoclq\Desktop\TEST PYTHON\QNPC.sav')
import xlrd
bus_excel_location = "C:/Users/ngoclq/Desktop/TEST PYTHON/Bus.xlsx" 
bus= xlrd.open_workbook(bus_excel_location)
bussheet= bus.sheet_by_index(0) 
bussheet.cell_value(0,0)
bussheet.nrows
bussheet.ncols

intgar=[0, 0, 0, 0]
realar=[0, 0, 0, 0, 0, 0, 0]
for k in range(1,bussheet.nrows):
    intgar[0]=bussheet.cell_value(k,9)
    intgar[1]=bussheet.cell_value(k,3)           
    intgar[2]=bussheet.cell_value(k,5)
    intgar[3]=bussheet.cell_value(k,7)    
    realar[0]=bussheet.cell_value(k,2)
    realar[1]=bussheet.cell_value(k,10)
    realar[2]=bussheet.cell_value(k,11)
    realar[3]=bussheet.cell_value(k,12)
    realar[4]=bussheet.cell_value(k,13)
    realar[5]=bussheet.cell_value(k,14)
    realar[6]=bussheet.cell_value(k,15)
    i=bussheet.cell_value(k,0)
    name=bussheet.cell_value(k,1)
    ierr=psspy.bus_data_3(i,intgar,realar,name)

Please help me show any error on that code and how to run python file .py to update data of bus as data on my excel file Tks for helps.

edit retag flag offensive close merge delete

1 answer

Sort by » oldest newest most voted
0

answered 2020-05-07 14:30:19 -0500

jconto gravatar image

can you post a few rows from the Bus.xlsx file?

You may explicitly define integer or floating vars like:

intgar[3]= int(bussheet.cell_value(k,7))    
realar[0]= float(bussheet.cell_value(k,2))
edit flag offensive delete link more

Comments

Tks for help! Bus excel like csv file exported from PSSE. I also tried convert like you said, but not So I found new method: result of my code is a list of coder format BAT_DATA_... to run direct on PSSE cmd

ngoclq.evncpc gravatar imagengoclq.evncpc ( 2020-05-12 22:17:13 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

[hide preview]

Question Tools

1 follower

Stats

Asked: 2020-05-06 20:28:47 -0500

Seen: 193 times

Last updated: May 07