Revision history  [back]

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 (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'


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 (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 

Traceback (most recent call last): File "E:\007\21.py", line 32, in 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'

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)

import os,syspsspy.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])

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")
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 case_root = os.path.splitext(sys.argv[1])[0] IndexError: list index out of range