Ask Your Question
0

EXPORT DATA from EXCEL to PSSE

asked 2017-07-11 22:42:08 -0500

Mike gravatar image

I am receiving an error at the end of my code when trying to load the information into PSSE. My goal is once all the data was organized how I wanted, the next step was to use that organized data and import it to PSSE. Everything before that works but once I use a PSSE API, nothing works. I get this error: psspy.bsys(1,0,[0.0,0.0],0,[],1,[bus],0,[],0,[]) File ".\psspy.py", line 46020, in bsys TypeError: an integer is required. So the code is listed below. 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 psspy
import redirect
import csv
psspy.throwPsseExceptions = True


STUDY_CASE = 'C:\Users\RoszkowskiM\Documents\Cases\Final\ceii_Case1_SUM_2017_5050_MMWG16PF_FINAL.sav'

LOAD_GEN_DATAFILE = 'C:\Users\RoszkowskiM\Documents\CSV Files\ASTECOR_TLA.csv'

psspy.psseinit(10000)
psspy.case(STUDY_CASE)



data = list(csv.reader(open(LOAD_GEN_DATAFILE)))
mydict = {}
for row in data:
  year,location,bus,change,isload = row[0:5]
# convert the types from string to Python numbers

change= float(change)
bus = int(bus)

#If this is a year not seen before, add it to the dictionary
  if year not in mydict:
      mydict[year] = {}
      busses_in_year = mydict[year]
  if location not in busses_in_year:
      busses_in_year[location] = []

   #Add the bus to the list of busses that stop at this location
   busses_in_year[location].append((bus, change,isload))


    # assume CSV has columns as described in the doc string
     year = raw_input("Select Year of Study: ")

     location = raw_input(" Select the number associated to the TLA Pocket Location:")

     if year in mydict and location in mydict[year]:  
     busses_in_year = mydict[year]
     print("Here are all the busses at that location for that year: ")
    for bus in busses_in_year[location]:
     print(bus)


    else:
       print("Invalid Year or Location")

       # I am trying to scale the generation by using these API's. It's based off the loaded information above. I guessed
            # and used bus and change to replace parts of the API with bsys and scal_2
      if isload.isdigit() and int(isload):    
          psspy.bsys(1,0,[0.0,0.0],0,[],1,[bus],0,[],0,[])
          psspy.scal_2(1,0,1,[0,0,0,0,0],[0.0,0.0,0.0,0.0,0.0,0.0,0.0])
          psspy.scal_2(0,1,2,[0,1,0,1,0],[change,0.0,0,-.0,0.0,-.0,0])
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2017-07-12 22:23:39 -0500

jconto gravatar image

The variables 'isload' and 'bus' are assumed to be integers,if not, use the function int(x) on them. The code below worked fine on the savnw.sav case for load at bus=3008, with change= 120.0

  # to scale load:
  if int(isload):    
      psspy.bsys(1,0,[0.0,0.0],0,[],1,[bus],0,[],0,[])
      psspy.scal_2(1,0,1,[0,0,0,0,0],[0.0,0.0,0.0,0.0,0.0,0.0,0.0])
      psspy.scal_2(1,0,2,[0,1,0,1,0],[change,0.0,0,-.0,0.0,-.0,0])
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

2 followers

Stats

Asked: 2017-07-11 22:42:08 -0500

Seen: 980 times

Last updated: Jul 12 '17