Ask Your Question
0

Reading a String value from CSV Sheet

asked 2017-08-20 23:02:07 -0500

Mike gravatar image

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],[])
edit retag flag offensive close merge delete

1 answer

Sort by » oldest newest most voted
0

answered 2017-08-21 00:56:55 -0500

perolofl gravatar image

Why are you converting variable digit to an integer when it contains the string T1? Remove line

digit = int(digit)

and use digit directly as a string in twowindingchng_4.

edit flag offensive delete link more

Comments

I tried that. It still gave me the same error

mikerosz gravatar imagemikerosz ( 2017-08-21 07:52:24 -0500 )edit

What is the result if you do print digit and print type(digit) before calling two_winding_chng_4?

perolofl gravatar imageperolofl ( 2017-08-21 10:08:30 -0500 )edit

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

1 follower

Stats

Asked: 2017-08-20 23:02:07 -0500

Seen: 282 times

Last updated: Aug 21 '17