> hi;
> say i have a text file with a string ( say '(XYZ)') and I want to find
> the number of line where this string has occured. What is the best way
> to do that?
I would suggest:
# Read file contents
lines = file('filename.txt').readlines()
# Extract first line number containing 'XYZ' string
M.N.A.Smadi wrote:
> hi;
> say i have a text file with a string ( say '(XYZ)') and I want to find
> the number of line where this string has occured. What is the best way
> to do that?
>
> what about if that string was say a 0 with leading and trailing white
> spaces, would that be any differen
M.N.A.Smadi wrote:
> hi;
> say i have a text file with a string ( say '(XYZ)') and I want to find
> the number of line where this string has occured. What is the best way
> to do that?
>
> what about if that string was say a 0 with leading and trailing white
> spaces, would that be any differen