1. str is the name of a builtin type object. If you create a variable with that name, then you will be unable to access that builtin type while your variable remained in scope. This would mean that you would be unable to call str(42), for example.

2. Perhaps the csv module can be of use to you? http://docs.python.org/2/library/csv.html

3. There's an easier way to test if there's a substring present in a string:

for line in f_read:
    if 'VON MISES' in line:
        print m

If you want case insensitivity, just replace line with line.upper().

4. By the way, you could probably also do this in one line from bash using grep:

grep "VON MISES" "file name" > "output file"

Jonathan

On 3/26/2013 11:41 PM, Kamalakar gs wrote:
Dear all,
I am newbie to coding.I want extract the data from text file which contains
text and tables.In a file i want to extract all "VON MISES" stress data
from a table.i wrote a code as below. but i dont know how to extract the
vonmises column data and dump it into text file.
So i am attaching the file which i am using for my project.

*
*
*import re*
*f_read = open('file name','r')*
*str='VON MISES'*
*for line in f_read:    *
*    m=re.search(str,line)*
*    if m:*
*     print m*
*
*
*
*
*Thanks regards Kamalakar*
_______________________________________________
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers


_______________________________________________
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers

Reply via email to