Re: file operations.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Fredrik Lundh

    Re: file operations.

    aditya shukla wrote:
    Guys thanks for your previous help .I have a doubt again
    (I'm sure you mean "a question"; in english, "a doubt" is something
    slightly different, and quite often more negative.)
    Also , because of this i am not able to extract the floating point
    values ie 0.50,0.50,0.66 respectively
    cause when i use the proposed solution given earlier
    >
    data=[]
    for line in x:
    print repr(line) # added for debugging!
    line=line.split ("|")
    data.append(flo at(line[-2])) --i am trying to get the floating
    point values from the back
    >
    i receive this error message
    >
    Traceback (most recent call last):
    File "<pyshell#7 1>", line 3, in <module>
    d.append(float( line[-2]))
    IndexError: list index out of range
    one or more lines in your file doesn't match the description; try adding
    a print statement (see above) to see what they might look like, and make
    sure that you filter them out (e.g. by checking the size of the list you
    get from the split, as Terry explains).

    </F>

Working...