2

The error in the code is

psspy.three_wnd_winding_data_3(from_,to,last_bus,r"""1""",1,[_i,_i,_i,_i,_i],[_f,_f,_f,_f,_f,_f,_f,_f, max_value, min_value,_f,_f,_f]) 

TypeError: an integer is required 

I thought I already converted the string into an integer. I am confused. Because the other variables year_link, tla_2, min_value, max_value did not require me to use isinstance and isdigit. The variables are being transferred into the psspy function array. The error says, it's reading a string value for last_bus. Does anyone know how to fix this and can explain to me why I have to convert the string for the last column of the excel sheet. Excel Sheet

for row in data:
     year_link, from_,to,digit,name2,tla_2,min_value,max_value,last_bus = row[7:16]
     if isinstance(last_bus, str) and year_link==year and tla_2==location and last_bus.isdigit() is True:
         min_value=float(min_value)
         max_value=float(max_value)
         last_bus=int(last_bus)

         output = 'From Bus #: {}\tTo Bus #: {}\tLast Bus #: {}\t Area Station: {}\t VMIN: {} pu\tVMAX: {} pu\t'
         print(output.format(from_, to,last_bus,name2, min_value, max_value))
         print("\n")
         psspy.three_wnd_winding_data_3(from_,to, last_bus,r"""1""",1,[_i,_i,_i,_i,_i],[_f,_f,_f,_f,_f,_f,_f,_f, max_value, min_value,_f,_f,_f]) 
     else:
         exit
  • At what point is `from_,to, last_bus,r"""1""",1,[_i,_i,_i,_i,_i],[_f,_f,_f,_f,_f,_f,_f,_f, max_value, min_value,_f,_f,_f]` an integer? This code is very difficult to understand, sorry. – roganjosh Aug 31 '17 at 19:03
  • May I see `print(type (last_bus))`? – stovfl Sep 01 '17 at 08:30
  • `From Bus #: 126418 To Bus #: 126595 Last Bus #: 126783 Area Station: Fresh Kills VMIN: 1.0076 pu VMAX: 1.0197 pu ` I am not sure what I did, but know it is working. Thanks @stovil for the help with that code you gave me that really helped me – Michael Roszkowski Sep 01 '17 at 12:28
  • @MichaelRoszkowski, please add code as an answer so others also can solve this problem in future – techkuz Sep 01 '17 at 13:50

1 Answers1

0

Excel doesn't have an integer data type; so from_ and to could actually be float objects in python.

Sending arguments to psspy functions in the format the record macro feature gives you is error-prone. The following approach using keyword arguments is better:

psspy.three_wnd_winding_data_3(
    ibus=int(from_),              # H winding bus
    jbus=int(to),                 # X winding bus
    kbus=int(last_bus),           # Y winding bus
    ckt='1',                      # circuit ID
    warg=1,                       # winding number
    realari9=float(max_value),    # VMAi
    realari10=float(min_value),   # VMIi
)    

Reading the docstring is crucial here. You can read the API documentation.

jeschwar
  • 1,286
  • 7
  • 10