Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Anyone can help me to debug the Python program?

I want to find all the .sav files in E:\007, and conver the generators and loads use cong( ) and conl( ) function, but there are some errors in the program I wrote, anyone can help me ?
Thank you very much!

import os,sys sys.path.append(r"C:\Program Files\PTI\PSSE33\PSSBIN") os.environ['PATH'] = r"C:\Program Files\PTI\PSSE33\PSSBIN;" + os.environ['PATH'] os.chdir(r"E:\007") import psspy import redirect import glob PYTHONPATH = r'C:\Program Files\PTI\PSSE33\EXAMPLE'

sys.path.append(PYTHONPATH) os.environ['PATH'] += ';' + PYTHONPATH

redirect.psse2py()

for CASE in glob.glob(os.path.join('E:\007\','*.sav')): psspy.psseinit(150000) psspy.case(CASE)

psspy.cong(0)
psspy.conl(0,1,1,[0,0],[0.0,0.0,0.0,0.0])
psspy.conl(0,1,2,[0,0],[0.0,0.0,0.0,0.0])
psspy.conl(0,1,3,[0,0],[0.0,0.0,0.0,0.0])

case_root = os.path.splitext(sys.argv[1])[0]
psspy.save(case_root + "_C.sav")

*Traceback (most recent call last): File "E:\007\21.py", line 32, in <module> case_root = os.path.splitext(sys.argv[1])[0] IndexError: list index out of range*

Anyone can help me to debug the Python program?

I want to find all the .sav files in E:\007, and conver the generators and loads use cong( ) and conl( ) function, but there are some errors in the program I wrote, anyone can help me ?
Thank you very much!

import os,sys
sys.path.append(r"C:\Program Files\PTI\PSSE33\PSSBIN")
os.environ['PATH'] = r"C:\Program Files\PTI\PSSE33\PSSBIN;" + os.environ['PATH']
os.chdir(r"E:\007")
import psspy
import redirect
import glob
PYTHONPATH = r'C:\Program Files\PTI\PSSE33\EXAMPLE'

Files\PTI\PSSE33\EXAMPLE' sys.path.append(PYTHONPATH) os.environ['PATH'] += ';' + PYTHONPATH

redirect.psse2py()

PYTHONPATH redirect.psse2py() for CASE in glob.glob(os.path.join('E:\007\','*.sav')): glob.glob(os.path.join('E:\\007\\','*.sav')): psspy.psseinit(150000) psspy.case(CASE)

psspy.case(CASE)

    psspy.cong(0)
 psspy.conl(0,1,1,[0,0],[0.0,0.0,0.0,0.0])
 psspy.conl(0,1,2,[0,0],[0.0,0.0,0.0,0.0])
 psspy.conl(0,1,3,[0,0],[0.0,0.0,0.0,0.0])

 case_root = os.path.splitext(sys.argv[1])[0]
 psspy.save(case_root + "_C.sav")

There ERRORS are as follow:

*Traceback (most recent call last): File "E:\007\21.py", line 32, in <module> case_root = os.path.splitext(sys.argv[1])[0] IndexError: list index out of range*

click to hide/show revision 3
No.3 Revision

Anyone can help me to debug the Python program?

I want to find all the .sav files in E:\007, and conver the generators and loads use cong( ) and conl( ) function, but there are some errors in the program I wrote, anyone can help me ?
Thank you very much!

import os,sys
sys.path.append(r"C:\Program Files\PTI\PSSE33\PSSBIN")
os.environ['PATH'] = r"C:\Program Files\PTI\PSSE33\PSSBIN;" + os.environ['PATH']
os.chdir(r"E:\007")
import psspy
import redirect
import glob
PYTHONPATH = r'C:\Program Files\PTI\PSSE33\EXAMPLE'


sys.path.append(PYTHONPATH)
os.environ['PATH'] += ';' + PYTHONPATH

redirect.psse2py()

for CASE in glob.glob(os.path.join('E:\\007\\','*.sav')):
    psspy.psseinit(150000)
    psspy.case(CASE)

    psspy.cong(0)
    psspy.conl(0,1,1,[0,0],[0.0,0.0,0.0,0.0])
    psspy.conl(0,1,2,[0,0],[0.0,0.0,0.0,0.0])
    psspy.conl(0,1,3,[0,0],[0.0,0.0,0.0,0.0])

    case_root = os.path.splitext(sys.argv[1])[0]
    psspy.save(case_root + "_C.sav")

There ERRORS are as follow:

*Traceback

Traceback (most recent call last):
  File "E:\007\21.py", line 32, in <module>
    case_root = os.path.splitext(sys.argv[1])[0]
IndexError: list index out of range*

range