Hi Shai, Thanks for the prompt reply. As a really beginner, I think I partly understand your idea, but I don't know how to do it. Can help with this? Assuming I prefer the first option to search on the entire file, I would start as follows: txt = file(r" project_release.dump").read() #now I should find the next x hexadecimal words (x value is known) that start after the string "RAW DATA:" in section that starts with " multiprogpage_d...@c2 - SECTION HEADER". How do I do that?
Thanks, Yitzhak -----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of Shai Berger Sent: Monday, May 24, 2010 6:34 PM To: [email protected] Subject: Re: [Python-il] [python-il]location in file Hi Yitzhak, You said, > > I am searching for data in file. The file is from type of text. I was > using RE for finding the location in file that I was interested in. but in the code, you wrote, > for line in s: [...] > if re.match(r".*RAW DATA.*", line): That is, instead of finding the location in the FILE, you found the location in the LINE. What you should do instead is get a string that contains your whole section; you can do this with regular expressions (applied to the whole file, s, with re.M), or you can do this by collecting the relevant lines after having split the file into lines. Then, just use section.split() to get a list of the "words" (as separated by whitespace) in the section. Have fun, Shai. _______________________________________________ Python-il mailing list [email protected] http://hamakor.org.il/cgi-bin/mailman/listinfo/python-il ______________________________________________________________________ DSP Group, Inc. automatically scans all emails and attachments using MessageLabs Email Security System. _____________________________________________________________________ ______________________________________________________________________ DSP Group, Inc. automatically scans all emails and attachments using MessageLabs Email Security System. _____________________________________________________________________ _______________________________________________ Python-il mailing list [email protected] http://hamakor.org.il/cgi-bin/mailman/listinfo/python-il
