Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5

Python float object has no attribute strip

#1
Hello , Merry Christmas hope this day finds you all well . I want to read the radius and the Sides which are two of my main Variables in order to have a programm in python which will take this Values to execute this code.The  Values are taken  from a CSV file radius.csv (it contains the value 1000 in the first shell), sides.csv(it contains the value 360 in the first shell) . I keep having the same error even thow I'm converting from float or int into 'Strip' . Can you please help . Thanks in advance 


this is the  lines  of the code that I'm reading the csv values
Code:
datar =LoadList(path_file_radius)
datas= LoadList(path_file_sides)    
nots = int(datas[0][0].strip("\ufeff").strip())
s = str(nots).strip("\ufeff")
print(f"Loaded value for r: {s}")
notr = int(datar[0][0].strip("\ufeff").strip())
r = str(notr).strip("\ufeff")
print(f"Loaded value for r: {r}")  
print (data)

I'm using it for this Line of code
posei = pi * rotz(ang) * transl(r, 0, 0) * rotz(-ang)
ang = i * 2 * math.pi /
s

   
#2
It looks like you are calling the strip function on a number (float value), you should not call strip on this number. If you still want to do it anyway, you should convert it to a string. 

For example a quick workaround could be to add str on the data read from your CSV file:
Code:
notr = int(str(datar[0][0]).strip("\ufeff").strip())
  




Users browsing this thread:
1 Guest(s)