n.org
[mailto:tutor-bounces+rweidner=ea@python.org] On Behalf Of Spencer Parker
Sent: Friday, April 10, 2009 1:00 PM
To: Kent Johnson
Cc: Alan Gauld; tutor@python.org
Subject: Re: [Tutor] ideas on how to process a file
The question is now...what do I do to find duplicate entries in the text file
On Fri, Apr 10, 2009 at 1:12 PM, Sander Sweers wrote:
> results = []
>
> for line in text_file:
> if 'FULLNAME' in line and line not in results:
> results.append(line)
> write_file.write(line)
In general it is better to use a set for this kind of application, it
will have much be
2009/4/10 Spencer Parker :
> The question is now...what do I do to find duplicate entries in the text
> file I am reading. I just want to filter them out. There are a ton of
> duplicate entries in there.
>>> for line in text_file: # No need for readlines(), a file is iterable
>>> if 'FULLNAME
The question is now...what do I do to find duplicate entries in the text
file I am reading. I just want to filter them out. There are a ton of
duplicate entries in there.
On Fri, Apr 10, 2009 at 10:43 AM, Spencer Parker wrote:
> Oh...nice...this makes things much easier than what I had before.
Oh...nice...this makes things much easier than what I had before.
I mainly used writelines because I couldn't figure out why it was only
writing one line. Then I did and never took out the writelines...I just did
and it works just fine for the most part.
Thanks again for the help.
On Fri, Apr 1
On Fri, Apr 10, 2009 at 12:04 PM, Spencer Parker wrote:
>
> This is my code:
> http://pastebin.com/m11053edf
I guess you have something like this now:
for line in text_file.readlines():
if line.find('FULLNAME')>=0:
write_file.writelines(line)
This can be better written a
I forgot to respond back to the list:
The only info I really need is the name. So I have been using readlines()
to go through and find the lines that have fullname,
if line.find("FULLNAME")>=0:
I am now having issues with it writing it to a file.
This is my code:
http://pastebin.com/m11053edf
"Spencer Parker" wrote in message
I have a flat file database that I want to get information from. The
basic
text looks like this:
ITEM{
"FULLNAME" "apps114.chgit.com!file:/etc"
"RECOVERY" "0"
}
They are all on a separate line in the text file. I had thought ab
I have a flat file database that I want to get information from. The basic
text looks like this:
ITEM{
"FULLNAME" "apps114.chgit.com!file:/etc"
"RECOVERY" "0"
}
They are all on a separate line in the text file. I had thought about
trying to drop it into a list or a