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
Excel doesn't have an integer data type; so
from_
andto
could actually befloat
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:Reading the docstring is crucial here. You can read the API documentation.