Re: [Tutor] Performing an union of two files containing keywords

2014-02-17 Thread Dave Angel
Oscar Benjamin Wrote in message: > On 17 February 2014 13:16, Dave Angel wrote: >> On 02/17/2014 06:12 AM, Oscar Benjamin wrote: >>> >>> Something like this: >>> >>> with open(r'D:\file3.txt', 'r+') as fout: >>> keywords_seen = set() >>> for filename in r'C:\File1.txt', r'C:\File2.txt'

Re: [Tutor] Performing an union of two files containing keywords

2014-02-17 Thread Oscar Benjamin
On 17 February 2014 13:16, Dave Angel wrote: > On 02/17/2014 06:12 AM, Oscar Benjamin wrote: >> >> Something like this: >> >> with open(r'D:\file3.txt', 'r+') as fout: >> keywords_seen = set() >> for filename in r'C:\File1.txt', r'C:\File2.txt': >> with open(filename) as fin: >>

Re: [Tutor] Performing an union of two files containing keywords

2014-02-17 Thread Dave Angel
On 02/17/2014 05:29 AM, spir wrote: On 02/17/2014 10:07 AM, Aaron Misquith wrote: I have 2 different text files. File1.txt contains: file RAMPython parser File2.txt contains: file1234 program I want to perform an union of these both files such that i get an output file3.txt which contains:

Re: [Tutor] Performing an union of two files containing keywords

2014-02-17 Thread Dave Angel
Aaron Misquith Wrote in message: > As two others have said, a set is the simplest solution to avoid duplicates. There are other questions to ask, however. Primary is whether order matters. If it does not, then observe that list(set(mylist)) will produce a list from a list without duplicate

Re: [Tutor] Performing an union of two files containing keywords

2014-02-17 Thread Dave Angel
On 02/17/2014 06:12 AM, Oscar Benjamin wrote: On 17 February 2014 09:07, Aaron Misquith wrote: The program that i'm working on just combines two files. Any help on performing an union such that a keyword would not be repeated would be appreciated. Code: with open("C:\\File1.txt") as fin1: lin

Re: [Tutor] Performing an union of two files containing keywords

2014-02-17 Thread Alan Gauld
On 17/02/14 10:29, spir wrote: I want to perform an union of these both files such that i get an output file3.txt which contains: file RAMPython parser1234 program I don't understand the logic of your "union" (???) at all. Is your example correct? It's an email formatting issue, I saw the s

Re: [Tutor] Performing an union of two files containing keywords

2014-02-17 Thread Oscar Benjamin
On 17 February 2014 09:07, Aaron Misquith wrote: > > The program that i'm working on just combines two files. Any help on > performing an union such that a keyword would not be repeated would be > appreciated. > > Code: > with open("C:\\File1.txt") as fin1: lines = fin1.readlines() > with open("C:

Re: [Tutor] Performing an union of two files containing keywords

2014-02-17 Thread spir
On 02/17/2014 10:07 AM, Aaron Misquith wrote: I have 2 different text files. File1.txt contains: file RAMPython parser File2.txt contains: file1234 program I want to perform an union of these both files such that i get an output file3.txt which contains: file RAMPython parser1234 program

Re: [Tutor] Performing an union of two files containing keywords

2014-02-17 Thread Peter Otten
Aaron Misquith wrote: > I have 2 different text files. > > File1.txt contains: > > file > RAMPython > parser > > File2.txt contains: > > file1234 > program > > I want to perform an union of these both files such that i get an output > file3.txt which contains: > > file > RAMPython > parser12

Re: [Tutor] Performing an union of two files containing keywords

2014-02-17 Thread Mark Lawrence
On 17/02/2014 09:07, Aaron Misquith wrote: I have 2 different text files. File1.txt contains: |file RAM Python parser| File2.txt contains: |file 1234 program| I want to perform an union of these both files such that i get an output file3.txt which contains: |file RAM Python parser 1234 prog

[Tutor] Performing an union of two files containing keywords

2014-02-17 Thread Aaron Misquith
I have 2 different text files. File1.txt contains: file RAMPython parser File2.txt contains: file1234 program I want to perform an union of these both files such that i get an output file3.txt which contains: file RAMPython parser1234 program The program that i'm working on just combines t