First time here? We are a friendly community of Power Systems Engineers. Check out the FAQ!
1 | initial version |
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()