Ask Your Question
0

psse network data to excel use python

asked 2018-01-22 09:51:39 -0600

YI-WEI gravatar image

How to program python code let psse network data to csv file & csv data to psse network data ? please give me some example thank very much !

I use psse ver33 & python 2.7

edit retag flag offensive close merge delete

1 answer

Sort by » oldest newest most voted
0

answered 2018-01-23 16:51:07 -0600

jaMineroR gravatar image

There are many API's that let you extract the information of the base case and save them into variables. You can then use the Python native way of creating a *.txt or *.csv file and output the information.

For example, a code that will export all the buses number and name of a certain subsystem to an csv file:

# Import library to manage *.csv files
import csv

# Get the name and path of the base case file
savname, snp = psspy.sfiles()
path = os.path.dirname(savname)

# Create the subsystem you want to work with
psspy.bsys(0, 1, [ 0.0, 500.0], 1, [20], 0, [], 0, [], 0, [])

# Obtain all of subsystem's buses numbers and names
busData_1 = psspy.abusint(0, 2, ["NUMBER"])[1][0]
busData_2 = psspy.abuschar(0, 2, ["NAME"])[1][0]

# Create *.csv file
csv_File = open(path + r"\buses.csv", 'w')

# Write buses number and name
for i, bus in enumerate(busData_1):

    csv_File.write("%i, %s\n" %(bus, busData_2[i]))

# File is saved and closed
csv_File.close()
edit flag offensive delete link more

Comments

Thank you for your code,where can I find the another api example?

YI-WEI gravatar imageYI-WEI ( 2018-01-25 00:00:52 -0600 )edit

You can check the PSSE documentation for information on all the API's that you can use. A good tool you can use is the recording python tool inside PSSE. You can do a recording to see which API's are used when you modify the parameter of an element, and then modify it yourself through Python.

jaMineroR gravatar imagejaMineroR ( 2018-01-25 13:09:22 -0600 )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: 2018-01-22 09:51:39 -0600

Seen: 1,298 times

Last updated: Jan 23 '18