By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,818 Members | 1,262 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,818 IT Pros & Developers. It's quick & easy.

To search for text in file and then returns the two lines following it

P: 1
Hoping someone can help on this one. Have got some great information here.

I need to search a text for for the string "Read {"

When found I then need to return the two line following it.

So...... text is
Read {
inputs 0
file Q:/path/path/file.png

I can find the string "Read {"
but not sure how to return the two lines aftetr it.
Actually want I want is the file path but only as they apply to "Reads" not other things in the file.



file Q:/path/path/file.png
Oct 31 '11 #1
Share this Question
Share on Google+
3 Replies


bvdet
Expert Mod 2.5K+
P: 2,851
Iterate on the file object: for line in fileObj:

If the target text is in line, return the next 2 lines:
Expand|Select|Wrap|Line Numbers
  1. return fileObject.readline(), fileObject.readline()
Oct 31 '11 #2

P: 1
i didn't get please reply once again.
Nov 2 '11 #3

bvdet
Expert Mod 2.5K+
P: 2,851
srikanthtullimi,

What is it you did not get?
Nov 2 '11 #4

Post your reply

Sign in to post your reply or Sign up for a free account.