abuschar data to excel
I'm trying to extract the information contained in a psse .raw file into a Excel file.
I'm doing pretty fine with data obtained from 'abusint' functions but I getting an error when I try to do the same with data obteined from ''abuschar'.
I guess the error that I'm getting is related to the data type that comes out from 'abuschar' (string type data instead of an integer).
I've not tried yet but i think i'll have the same issue when i'll use 'abrncplx' to get complex impedances of branches.
I'm using pandas to write data into Excel.
I'll be most grateful if somebody could help me with this "psse + pandas" related issue!!
Thanks.
NOTE: Find next the code that I'm using for that:
# Base case is loaded ================================================================================================================================
psspy.case(path + "\\" + base_case)
# Data is read from .raw file ========================================================================================================================
ierr, BusNumber = psspy.abusint(sid, string='NUMBER')
ierr, BusName = psspy.abuschar(sid, string='NAME')
ierr, FromName = psspy.abrnchar(sid, string='FROMNAME')
ierr, ToName = psspy.abrnchar(sid, string='TONAME')
ierr, FromNum = psspy.abrnint(sid, string='FROMNUMBER')
ierr, ToNum = psspy.abrnint(sid, string='TONUMBER')
ierr, Length = psspy.abrnreal(sid,string='LENGTH')
ierr, Impedance = psspy.abrncplx(sid,string='RX')
ierr, Losses = psspy.abrncplx(sid,string='PQLOSS')
ierr, MachNum = psspy.amachint(sid, string='NUMBER')
ierr, MachStatus = psspy.amachint(sid, string='STATUS')
ierr, MachID = psspy.amachchar(sid, string='ID')
ierr, LoadNum = psspy.aloadint(sid, string='NUMBER')
ierr, LoadStatus = psspy.aloadint(sid, string='STATUS')
ierr, LoadValue = psspy.aloadreal(sid, string='MVAACT')
ierr, LoadID = psspy.aloadchar(sid, string='ID')
## PSSE returns a "list of lists" for each of the subsystem data retrieval functions
## We need to pull out the first element of each to make it easier to work with:
BusNumber = BusNumber[0]
BusName = BusName[0]
FromNum = FromNum[0]
ToNum = ToNum[0]
FromName = FromName[0]
ToName = ToName[0]
Length = Length[0]
Impedance = Impedance[0]
Losses = Losses[0]
MachNum = MachNum[0]
MachStatus = MachStatus[0]
MachID = MachID[0]
LoadNum = LoadNum[0]
LoadStatus = LoadStatus[0]
LoadValue = LoadValue[0]
LoadID = LoadID[0]
BusList = []
for i in range(len(BusNumber)):
BusList.append([BusNumber[i], BusName[i]])
BranchList = []
for i in range(len(FromNum)):
BranchList.append([FromNum[i], ToNum[i], FromName[i], ToName[i], Length[i], Impedance[i], Losses[i]])
MachineList = []
for i in range(len(MachNum)):
MachineList.append([MachNum[i], MachStatus[i], MachID[i]])
LoadList = []
for i in range(len(LoadNum)):
LoadList.append([LoadNum[i], LoadStatus[i], LoadValue[i], LoadID[i]])
busNumber = []
busName = []
fromBus = []
toBus = []
fromName = []
toName = []
length = []
impedance = []
losses = []
machNum = []
machStatus = []
machID = []
loadNum = []
loadStatus = []
loadValue = []
loadID = []
for i in range(len(BusList)):
busNumber.append(BusList[i][0])
busName.append(BusList[i][1])
for i in range(len(BranchList)):
fromBus.append(BranchList[i][0])
toBus.append(BranchList[i][1])
fromName.append(BranchList[i][2])
toName.append(BranchList[i][3])
length.append(BranchList[i][4])
impedance.append(BranchList[i][5])
losses.append(BranchList[i][6])
for i in range(len(MachineList)):
machNum.append(MachineList[i][0])
machStatus.append(MachineList[i][1])
machID.append(MachineList[i][2 ...