Ask Your Question

Mike's profile - activity

2019-01-21 10:11:32 -0500 received badge  Famous Question (source)
2018-02-05 01:48:36 -0500 received badge  Famous Question (source)
2017-11-19 17:21:29 -0500 received badge  Famous Question (source)
2017-10-04 08:39:04 -0500 received badge  Notable Question (source)
2017-09-01 08:50:05 -0500 received badge  Popular Question (source)
2017-08-20 23:02:07 -0500 asked a question Reading a String value from CSV Sheet

I am receiving an integer error when reading from my CSV sheet. Its giving me problems reading the last column. I know theres characters in the last column but how do I define digit as a character. The API function psspy.two_winding_chg_4 requires an input using single quotes ' ' as shown below in that function(3rd element of the array)excel sheet

Traceback (most recent call last):
File "C:\Users\RoszkowskiM\Desktop\win4.py", line 133, in <module>
psspy.two_winding_chng_4(from_,to,'%s'%digit,[_i,_i,_i,_i,_i,_i,_i,_i,_i,_i,_i,_i,_i,_i,_i],[_f,_f,_f,_f,_f,_f,_f,_f,_f,_f,_f,_f,_f,_f,_f,_f,_f,_f,_f, max_value, min_value,_f,_f,_f],[])
File ".\psspy.py", line 25578, in two_winding_chng_4
TypeError: an integer is required
ValueError: invalid literal for int() with base 10: 'T1'

for row in data:
    data_location, year_link, from_, to, min_value,max_value,name2,tla_2,digit = row[5:14]
    output = 'From Bus #: {}\tTo Bus #: {}\tVMAX: {} pu\tVMIN: {} pu\t'
    if year_link == year and data_location == location and tla_2==location:
       from_=int(from_)
       to=int(to)
       min_value=float(min_value)
       max_value=float(max_value)
       digit=int(digit)
       print(output.format(from_, to, max_value, min_value))
      _i=psspy.getdefaultint()
      _f=psspy.getdefaultreal()
       psspy.two_winding_chng_4(from_,to,'%s'%digit,[_i,_i,_i,_i,_i,_i,_i,_i,_i,_i,_i,_i,_i,_i,_i],[_f,_f,_f,_f,_f,_f,_f,_f,_f,_f,_f,_f,_f,_f,_f,_f,_f,_f,_f, max_value, min_value,_f,_f,_f],[])
2017-08-20 02:32:55 -0500 received badge  Notable Question (source)
2017-08-17 10:53:33 -0500 received badge  Popular Question (source)
2017-08-15 18:41:25 -0500 asked a question variable error and storing variable into single quote ' '

below is a portion of code where data is read from an excel file and is transferred into a psspy function. I am receiving an error about _i and _f not being variables. But I received this code by running an ibdev on PSSE. Is there any way to change this so the error is eliminated. I tried using the API's default variables but it didn't work as well. Also for the third element in the array, I'm trying to put a variable into a string so it can loop through multiple characters in my excel sheet. Is that the correct way of doing it? Attached are the API's for this particular function and capability.API 1API 2API 3

    for row in data:
    data_location, year_link, from_, to, max_value, min_value,digit = row[5:12]
    output = 'From Bus #: {}\tTo Bus #: {}\tVMAX: {} pu\tVMIN: {} pu\t'
      if year_link == year and data_location == location:
         print(output.format(from_, to, max_value, min_value))

   psspy.two_winding_chng_4(from_,to,'%s'%digit,[_i,_i,_i,_i,_i,_i,_i,_i,_i,_i,_i,_i,_i,_i,_i]
   [_f,_f,_f,_f,_f,_f,_f,_f,_f,_f,_f,_f,_f,_f,_f,_f,_f,_f,_f, max_value, min_value,_f,_f,_f],[])
2017-08-07 15:42:17 -0500 received badge  Famous Question (source)
2017-08-02 09:48:50 -0500 received badge  Notable Question (source)
2017-07-25 01:22:33 -0500 received badge  Popular Question (source)
2017-07-19 13:16:54 -0500 received badge  Notable Question (source)
2017-07-17 18:11:30 -0500 asked a question Using MODULE EXCELPY to READ data

Hello everyone, I am trying to use this code which I posted in another question on this website. My goal now is this read data but this time using the module EXCELPY. I lloked into the API documentation and I could only find information about writing excel files. What I am trying to do is to read the excel data and using that data, import it into PSSE. Any help would be appreciated.

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])
2017-07-17 18:03:58 -0500 received badge  Popular Question (source)
2017-07-17 18:01:58 -0500 commented answer Importing data from Excel and Scaling areas

Hello JConta, I was reading your answer to a post from the PSSE help forum about importing data from Excel and scaling areas. I tried accessing the code you posted but it wasn't found. Any way you can send it to me when you get the chance? Thank you and have a nice day. - Mike

2017-07-11 22:42:08 -0500 asked a question EXPORT DATA from EXCEL to PSSE

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])