Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Unable to save to txt

The code below does not write to txt. What am i doing wrong?

import os, sys

PSSELOCATION = r"C:\Program Files (x86)\PTI\PSSE33\PSSBIN" sys.path.append(PSSELOCATION) os.environ['PATH'] = os.environ['PATH'] + ';' + PSSE_LOCATION

import glob import psspy import redirect

redirect.psse2py()

FileNumber = 1

Loop through cases

for CASE in glob.glob(os.path.join('C:\Users\tshipam\Desktop\SAPP temp\PSSE Engine mode\', '*.sav')):

psspy.psseinit(12000)
psspy.case(CASE)
psspy.throwPsseException = True

psspy.fdns([1,0,0,0,0,0,99,0])

conFile = open('report.txt', 'w')
conFile.write('Started writing to file by Mutenda Tshipala')
conFile.write('\n\n')

# Redirect generated reports to a file
psspy.report_output(islct=2, filarg="./" + 'report' + '.txt', options=[0])
##psspy.report_output(islct=2, filarg="./" + 'report' + FileNumber + '.txt', options=[0])    

# Run any functions that create a report
psspy.lout(0,1)

# Redirect reports back to the default      
psspy.report_output(islct=2, options=[0])

##conFile.write('Finished writing to file by Mutenda Tshipala')
conFile.close()

Unable to save to txt

The code below does not write to txt. is creating multiple headers. What am i doing wrong?

import os, sys

PSSELOCATION = r"C:\Program Files (x86)\PTI\PSSE33\PSSBIN" sys.path.append(PSSELOCATION) os.environ['PATH'] = os.environ['PATH'] + ';' + PSSE_LOCATION

import glob import psspy import redirect

redirect.psse2py()

FileNumber = 1

Loop through cases

for CASE in glob.glob(os.path.join('C:\Users\tshipam\Desktop\SAPP temp\PSSE Engine mode\', '*.sav')):'*.sav')): psspy.psseinit(12000) psspy.case(CASE) psspy.throwPsseException = True

psspy.psseinit(12000)
psspy.case(CASE)
psspy.throwPsseException = True

psspy.fdns([1,0,0,0,0,0,99,0])

conFile = open('report.txt', 'w')
conFile.write('Started writing to file by Mutenda Tshipala')
conFile.write('\n\n')

# Redirect generated reports to a file
psspy.report_output(islct=2, filarg="./" + 'report' + '.txt', options=[0])
##psspy.report_output(islct=2, filarg="./" + 'report' + FileNumber + '.txt', options=[0])    

# Run any functions that create a report
psspy.lout(0,1)

# Redirect reports back to the default      
psspy.report_output(islct=2, options=[0])

##conFile.write('Finished writing to file by Mutenda Tshipala')
conFile.close()

Output PTI INTERACTIVE POWER SYSTEM SIMULATOR--PSS(R)E TUE, MAY 16 2017 19:21 TXGPMASTERPROJECT 2016 TX2016 POST TDP-2017 BASE CASE %MVA FOR TRANSFORMERS POWERFACTORY 15.2.3 DATE: 2/26/2017, TIME: 10:53:06 AM %MVA FOR NON-TRANSFORMER BRANCHES

X------- FROM BUS ------X AREA VOLT GEN LOAD SHUNT X---------- TO BUS ----------X TRANSFORMER RATING BUS# X-- NAME --X BASKV ZONE PU/KV ANGLE MW/MVAR MW/MVAR MW/MVAR BUS# X-- NAME --X BASKV AREA CKT MW MVAR RATIO ANGLE % SET A

11 HPSC1B      400.00   12 1.0407   18.6     0.0      0.0     0.0 -----------------------------------------------------------------------------
                       112 416.26            0.0      0.0     0.0     16 HPSC1A      400.00   12  1   -171.0    25.7                   12  1455
                                                                     380 POSDN4      400.00   13  1    171.0   -25.7                   16  1109

. . .

TXGPMASTERPROJECT 2016 TX2016 POST TDP-2017 BASE CASE %MVA FOR TRANSFORMERS POWERFACTORY 15.2.3 DATE: 2/26/2017, TIME: 10:53:06 AM %MVA FOR NON-TRANSFORMER BRANCHES

X------- FROM BUS ------X AREA VOLT GEN LOAD SHUNT X---------- TO BUS ----------X TRANSFORMER RATING BUS# X-- NAME --X BASKV ZONE PU/KV ANGLE MW/MVAR MW/MVAR MW/MVAR BUS# X-- NAME --X BASKV AREA CKT MW MVAR RATIO ANGLE % SET A

58 KAPPA7      765.00    5 1.0415   13.5     0.0      0.0     0.0 -----------------------------------------------------------------------------
                       178 796.77            0.0      0.0     0.0     55 GAMMA7      765.00   10  1   -499.2    -8.6                   12  4174
                                                                      70 STERKUS7    765.00    5  1    304.9   -65.3                    4  7243
                                                                  3WNDTR KAPPA 765/40 WND 1       1    194.3    73.9  1.000RG          10  2000
click to hide/show revision 3
No.3 Revision

Unable to save to txtreport_output creating multiple headers

The code below is creating multiple headers. What am i doing wrong?

import os, sys

PSSELOCATION sys PSSE_LOCATION = r"C:\Program Files (x86)\PTI\PSSE33\PSSBIN" sys.path.append(PSSELOCATION) sys.path.append(PSSE_LOCATION) os.environ['PATH'] = os.environ['PATH'] + ';' + PSSE_LOCATION

PSSE_LOCATION import glob import psspy import redirect

redirect.psse2py()

redirect ##redirect.psse2py() for CASE in glob.glob(os.path.join('C:\Users\tshipam\Desktop\SAPP temp\PSSE glob.glob(os.path.join('C:\\Users\\tshipam\\Desktop\\SAPP temp\\PSSE Engine mode\', mode\\', '*.sav')): psspy.psseinit(12000) psspy.case(CASE) psspy.throwPsseException = True

True

psspy.fdns([1,0,0,0,0,0,99,0])

conFile = open('report.txt', 'w')
conFile.write('Started writing to file by Mutenda Tshipala')
conFile.write('\n\n')

# Redirect generated reports to a file
psspy.report_output(islct=2, filarg="./" + 'report' + '.txt', options=[0])
##psspy.report_output(islct=2, filarg="./" + 'report' + FileNumber + '.txt', options=[0])    

# Run any functions that create a report
psspy.lout(0,1)

Output PTI INTERACTIVE POWER SYSTEM SIMULATOR--PSS(R)E TUE, MAY 16 2017 19:21 TXGPMASTERPROJECT 2016 TX2016 POST TDP-2017 BASE CASE %MVA FOR TRANSFORMERS POWERFACTORY 15.2.3 DATE: 2/26/2017, TIME: 10:53:06 AM %MVA FOR NON-TRANSFORMER BRANCHES

X------- FROM BUS ------X AREA VOLT GEN LOAD SHUNT X---------- TO BUS ----------X TRANSFORMER RATING BUS# X-- NAME --X BASKV ZONE PU/KV ANGLE MW/MVAR MW/MVAR MW/MVAR BUS# X-- NAME --X BASKV AREA CKT MW MVAR RATIO ANGLE % SET A

11 HPSC1B      400.00   12 1.0407   18.6     0.0      0.0     0.0 -----------------------------------------------------------------------------
                       112 416.26            0.0      0.0     0.0     16 HPSC1A      400.00   12  1   -171.0    25.7                   12  1455
                                                                     380 POSDN4      400.00   13  1    171.0   -25.7                   16  1109

. . .

TXGPMASTERPROJECT 2016 TX2016 POST TDP-2017 BASE CASE %MVA FOR TRANSFORMERS POWERFACTORY 15.2.3 DATE: 2/26/2017, TIME: 10:53:06 AM %MVA FOR NON-TRANSFORMER BRANCHES

X------- FROM BUS ------X AREA VOLT GEN LOAD SHUNT X---------- TO BUS ----------X TRANSFORMER RATING BUS# X-- NAME --X BASKV ZONE PU/KV ANGLE MW/MVAR MW/MVAR MW/MVAR BUS# X-- NAME --X BASKV AREA CKT MW MVAR RATIO ANGLE % SET A

58 KAPPA7      765.00    5 1.0415   13.5     0.0      0.0     0.0 -----------------------------------------------------------------------------
                       178 796.77            0.0      0.0     0.0     55 GAMMA7      765.00   10  1   -499.2    -8.6                   12  4174
                                                                      70 STERKUS7    765.00    5  1    304.9   -65.3                    4  7243
                                                                  3WNDTR KAPPA 765/40 WND 1       1    194.3    73.9  1.000RG          10  2000