Ask Your Question
0

Unable to save to txt

asked 2017-05-16 12:02:48 -0500

Mutenda gravatar image

updated 2017-05-16 22:18:00 -0500

jconto gravatar image

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

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

import glob
import psspy
import redirect
##redirect.psse2py()
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)

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
edit retag flag offensive close merge delete

3 answers

Sort by ยป oldest newest most voted
0

answered 2017-05-21 23:50:09 -0500

perolofl gravatar image

Try to add the line:

psspy.lines_per_page_one_device(1,9999)

before lout

edit flag offensive delete link more
0

answered 2017-05-16 22:21:18 -0500

jconto gravatar image

updated 2017-05-18 10:23:52 -0500

Try having the command "psspy.psseinit(12000)" before the main for loop. Also put the file opening commands outside the loop. You will still get multiple headers!
The activity "LOUT" has a fixed-length text formatted output (approx. 60 lines x 150 cols) and information overflowing will generate a second 'page' with headers and all.

Text parsing using python might be a solution to eliminate unwanted headers.

edit flag offensive delete link more
0

answered 2017-05-18 08:32:40 -0500

Mutenda gravatar image

The command "psspy.psseinit(12000)" is now before the main for loop. The code still generates multiple headers.

edit flag offensive delete link more

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: 2017-05-16 12:02:48 -0500

Seen: 475 times

Last updated: May 21 '17