Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations IDS on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

PYTHON; 'invalid literal for float<>: "X" ERROR ??? 1

Status
Not open for further replies.

muffiny

Civil/Environmental
Jun 22, 2007
6
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:
the input file:
 
Replies continue below

Recommended for you

The first line of "source.txt" contains:
"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"
 
Hi Xerf
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)
TypeError:append() takes exactly one argument (2 given)"
any help would be appeciated
melody
 
TypeError:append() takes exactly one argument (2 given)"

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.
 
Hi Xerf
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
 
before:
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.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor