Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

You could use excelpy but personally I prefer writing into CSV, which is smaller and quicker. You could do something like this.

# get bus numbers, circuit IDs and loading of in-service branches
ierr,busnum = psspy.abrnint(string=['FROMNUMBER','TONUMBER'])
ierr,(ckt,) = psspy.abrnchar(string='ID')
ierr,loading = psspy.abrnreal(string=['P','Q'])

# open a file for writing
csv_out = open('branch_flows.csv','wb')

# create the csv writer object
mywriter = csv.writer(csv_out)

# write header
mywriter.writerow(('From bus','To bus','ID','MW','MVAr'))

# write data
mywriter.writerows(zip(busnum[0],busnum[1],ckt,loading[0],loading[1]))

# close CSV file
csv_out.close()

You could use excelpy but personally I prefer writing into CSV, which is smaller and quicker. You could do something like this.CSV.

# get bus numbers, circuit IDs and loading of in-service branches
ierr,busnum = psspy.abrnint(string=['FROMNUMBER','TONUMBER'])
ierr,(ckt,) = psspy.abrnchar(string='ID')
ierr,loading = psspy.abrnreal(string=['P','Q'])

# open a file for writing
csv_out = open('branch_flows.csv','wb')

# create the csv writer object
mywriter = csv.writer(csv_out)

# write header
mywriter.writerow(('From bus','To bus','ID','MW','MVAr'))

# write data
mywriter.writerows(zip(busnum[0],busnum[1],ckt,loading[0],loading[1]))

# close CSV file
csv_out.close()

You could can either use excelpy but personally or CSV module. I prefer writing into CSV.would stick to CSV if you were to store plain data, i.e. no requirements for features of XLSX etc.

First of all, get the data that you need.

# get bus numbers, circuit IDs and loading of in-service branches
ierr,busnum = psspy.abrnint(string=['FROMNUMBER','TONUMBER'])
ierr,(ckt,) ierr,ckt = psspy.abrnchar(string='ID')
ierr,loading = psspy.abrnreal(string=['P','Q'])

CSV option:

# open a CSV file for writing
csv_out = open('branch_flows.csv','wb')

# create the csv writer object
mywriter = csvobj= csv.writer(csv_out)

# write header
mywriter.writerow(('From csvobj.writerow(('From bus','To bus','ID','MW','MVAr'))

# write data
mywriter.writerows(zip(busnum[0],busnum[1],ckt,loading[0],loading[1]))
csvobj.writerows(zip(busnum[0],busnum[1],ckt[0],loading[0],loading[1]))

# close CSV file
csv_out.close()

excelpy option:

# create a Excel workbook for writing
xlobj = excelpy.workbook()

# write header
xlobj.set_range(1,'a',['From bus','To bus','ID','MW','MVAr'])

# write data
xlobj.set_range(2,'a',zip(*busnum))
xlobj.set_range(2,'c',zip(*ckt))
xlobj.set_range(2,'d',zip(*loading))

# save workbook
xlobj.save('branch_flows.xlsx')

You can either use excelpy or CSV module. I would stick to CSV if you were to store plain data, i.e. no requirements for features of XLSX etc.

First of all, get the data that you need.

# get bus numbers, circuit IDs and loading of in-service branches
ierr,busnum = psspy.abrnint(string=['FROMNUMBER','TONUMBER'])
ierr,ckt = psspy.abrnchar(string='ID')
ierr,loading = psspy.abrnreal(string=['P','Q'])

CSV option:

import csv

# open a CSV file for writing
csv_out = open('branch_flows.csv','wb')

# create the csv writer object
csvobj= csv.writer(csv_out)

# write header
csvobj.writerow(('From bus','To bus','ID','MW','MVAr'))

# write data
csvobj.writerows(zip(busnum[0],busnum[1],ckt[0],loading[0],loading[1]))

# close CSV file
csv_out.close()

excelpy option:

import excelpy

# create a Excel workbook for writing
xlobj = excelpy.workbook()

# write header
xlobj.set_range(1,'a',['From bus','To bus','ID','MW','MVAr'])

# write data
xlobj.set_range(2,'a',zip(*busnum))
xlobj.set_range(2,'c',zip(*ckt))
xlobj.set_range(2,'d',zip(*loading))

# save workbook
xlobj.save('branch_flows.xlsx')