Re: [Tutor] Script to search in string of values from file A in file B

2012-05-10 Thread Dave Angel
On 05/10/2012 04:20 AM, Afonso Duarte wrote: > Dear All, > > Thanks Joel and Walter, both solutions worked nicely and produced the desired > final objective! > > Short answer to Alan Gauld, far from me to start answering all your points, > but I guess I should answer to the most pertinent ones:

Re: [Tutor] Script to search in string of values from file A in file B

2012-05-10 Thread Afonso Duarte
ained when it wasn't). Thanks again for the nice solutions and sorry for the side discussion on how to write/answer to mailing lists Cheers Afonso -Original Message- From: Joel Goldstick [mailto:joel.goldst...@gmail.com] Sent: woensdag 9 mei 2012 20:47 To: Afonso Duarte Cc: tutor@

Re: [Tutor] Script to search in string of values from file A in file B

2012-05-09 Thread Alan Gauld
On 09/05/12 20:28, aduarte wrote: Sorry it seems that I got the wrong mailing list to subscribe ... I got the idea that this list was open to newbies ... by the answers I got I see that I was wrong I'm not sure what you mean. The answers you got seem to have provided the answers to your quest

Re: [Tutor] Script to search in string of values from file A in file B

2012-05-09 Thread Walter Prins
Hi Alfonso, I see you've had some responses yet -- I've not read them all, and am just posting the following suggestion you might want to look at: # read lines with "keys" into a list selected_keys=open('A.txt', 'r').readlines() # read all data records into another list records=open('B.txt', 'r')

Re: [Tutor] Script to search in string of values from file A in file B

2012-05-09 Thread Joel Goldstick
On Wed, May 9, 2012 at 3:40 PM, Joel Goldstick wrote: > On Wed, May 9, 2012 at 10:00 AM, Afonso Duarte wrote: >> Dear All, >> >> >> >> I’m new to Python and started to use it to search text strings in big >> (>500Mb) txt files. >> >> I have a list on text file (e.g. A.txt) that I want to use as a

Re: [Tutor] Script to search in string of values from file A in file B

2012-05-09 Thread Joel Goldstick
On Wed, May 9, 2012 at 10:00 AM, Afonso Duarte wrote: > Dear All, > > > > I’m new to Python and started to use it to search text strings in big > (>500Mb) txt files. > > I have a list on text file (e.g. A.txt) that I want to use as a key to > search another file (e.g. B.txt), organized in the foll

Re: [Tutor] Script to search in string of values from file A in file B

2012-05-09 Thread aduarte
Dear All, Sorry it seems that I got the wrong mailing list to subscribe ... I got the idea that this list was open to newbies ... by the answers I got I see that I was wrong " In that case, what do you use for data of the last key? If you really have to handle the case where there is a

Re: [Tutor] Script to search in string of values from file A in file B

2012-05-09 Thread Mark Lawrence
On 09/05/2012 15:00, Afonso Duarte wrote: object = open(B.txt', 'r') You'll already received some sound advice, so I'd just like to point out that your object will override the built-in object, apologies if somebody has already said this and I've missed it. Afonso __

Re: [Tutor] Script to search in string of values from file A in file B

2012-05-09 Thread Dave Angel
> > > If you really have to handle the case where there is a final key with no > data, then you'll have to detect that case, and make up the data > separately. That could be done with a try block, but this is probably > clearer: > > rawlines = object.readlines() > if len(rawlines) %2 != 0: >

Re: [Tutor] Script to search in string of values from file A in file B

2012-05-09 Thread Dave Angel
On 05/09/2012 11:04 AM, Afonso Duarte wrote: > > > -Original Message- > From: Dave Angel [mailto:d...@davea.name] > >> >> Please post your messages as plain-text. The double-spacing I get is >> very annoying. > > Sorry for that my outlook mess-it-up I'm sure there's a setting to say

Re: [Tutor] Script to search in string of values from file A in file B

2012-05-09 Thread Afonso Duarte
-Original Message- From: Dave Angel [mailto:d...@davea.name] Sent: woensdag 9 mei 2012 15:52 To: Afonso Duarte Cc: tutor@python.org Subject: Re: [Tutor] Script to search in string of values from file A in file B On 05/09/2012 10:00 AM, Afonso Duarte wrote: > Dear All, > I&#x

Re: [Tutor] Script to search in string of values from file A in file B

2012-05-09 Thread Dave Angel
On 05/09/2012 10:00 AM, Afonso Duarte wrote: > Dear All, > > > > I'm new to Python and started to use it to search text strings in big > (>500Mb) txt files. > > I have a list on text file (e.g. A.txt) that I want to use as a key to > search another file (e.g. B.txt), organized in the following w

Re: [Tutor] Script to search in string of values from file A in file B

2012-05-09 Thread aduarte
On 2012-05-09 15:22, BRAGA, Bruno wrote: On Thursday, May 10, 2012, Afonso Duarte wrote: Dear All,   I’m new to Python and started to use it to search text strings in big (>500Mb) txt files. > I have a list on text file (e.g. A.txt) that I want to use as a key to search another file (e.g.

Re: [Tutor] Script to search in string of values from file A in file B

2012-05-09 Thread BRAGA, Bruno
On Thursday, May 10, 2012, Afonso Duarte wrote: > Dear All, > > > > I’m new to Python and started to use it to search text strings in big (>500Mb) txt files. > > I have a list on text file (e.g. A.txt) that I want to use as a key to search another file (e.g. B.txt), organized in the following way:

[Tutor] Script to search in string of values from file A in file B

2012-05-09 Thread Afonso Duarte
Dear All, I'm new to Python and started to use it to search text strings in big (>500Mb) txt files. I have a list on text file (e.g. A.txt) that I want to use as a key to search another file (e.g. B.txt), organized in the following way: A.txt: Aaa Bbb Ccc Ddd . . . B.txt