PYTHON; 'invalid literal for float<>: "X" ERROR ???
PYTHON; 'invalid literal for float<>: "X" ERROR ???
(OP)
Hi there I am a newbie to python.I have attached a link to the script and the input file which it uses.When I run the script in abaqus command, I get the following error :File"nodes-els.py",line 9,in?
textlines.append<map<string.atof,string.split<line,','>>>
file "python/lib/string.py"line 200,in atof
valueerror:invalid literal for float <> :"X"
how can I address this error . . .
thank you melody
the script:
http://www.zshare.net/download/23841396220f15/
the input file:
http://www.zshare.net/download/2384160eea9b4e/
textlines.append<map<string.atof,string.split<line,','>>>
file "python/lib/string.py"line 200,in atof
valueerror:invalid literal for float <> :"X"
how can I address this error . . .
thank you melody
the script:
http://www.zshare.net/download/23841396220f15/
the input file:
http://www.zshare.net/download/2384160eea9b4e/





RE: PYTHON; 'invalid literal for float<>: "X" ERROR ???
"X","Y","Z"
Obviously, these cannot converted to float.
Hence, the error given by the code on line 9:
valueerror:invalid literal for float <> :"X"
RE: PYTHON; 'invalid literal for float<>: "X" ERROR ???
thank you for your help, I deleted the X,Y,Z line from the source file
I have another problem further down the script . . .
"line 31, in <module>
tempList.append (i+1,textLines[i])
TypeError:append() takes exactly one argument (2 given)"
any help would be appeciated
melody
RE: PYTHON; 'invalid literal for float<>: "X" ERROR ???
The "append(value)" method takes one argument 'value' and appends it at the end of the list. The index is not necessary.
You might be interested in the "insert(index,value)" method.
RE: PYTHON; 'invalid literal for float<>: "X" ERROR ???
thank you for your help
I made the changes you suggested, which resolved the problem.
I have another error message further down the script,
",line 39,in?
ycoordjs=newList[j][0][1][1]
TypeError:unscriptable object"
how can I go about resolving this . . .
melody
RE: PYTHON; 'invalid literal for float<>: "X" ERROR ???
ycoordjs=newList[j][0][1][1]
put:
print newList[j]
print newList[j][0]
print newList[j][0][1]
and see if that is what you expect to find at that combination of indices.