Python Forum

Full Version: Integer Required for psspy function
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
The error in the code is
Error:
psspy.three_wnd_winding_data_3(from_,to,'%s'% 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. 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.


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