473,320 Members | 1,876 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Modifying a text file

I want to remove duplicate entries within a text file. So if I had
this within a text file...

Applications/Diabetic Registry/
Applications/Diabetic Registry/
Applications/Diabetic Registry/
Applications/Great Plains/
Applications/Great Plains/
Applications/Great Plains/
Applications/Great Plains/Servers/
Applications/Great Plains/Servers/
Applications/HeartBase/
Applications/HeartBase/
Applications/HeartBase/
Applications/HHC/
Applications/HHC/
Applications/HHC/
Applications/HHC/

I would want the result to be this:

Applications/Diabetic Registry/
Applications/Great Plains/
Applications/Great Plains/Servers/
Applications/HeartBase/
Applications/HHC/

I've tried using StreamReader and StreamWriter simulataneously with no
success...any other ideas?

Jan 23 '06 #1
6 1171
If the file isn't very large you could load all the lines of the file
into an array and remove duplicates from the array and rewrite the
file. If you need code on how to remove duplicates using an array let
me know and I'll post it.

-Nelson
soup_nazi wrote:
I want to remove duplicate entries within a text file. So if I had
this within a text file...

Applications/Diabetic Registry/
Applications/Diabetic Registry/
Applications/Diabetic Registry/
Applications/Great Plains/
Applications/Great Plains/
Applications/Great Plains/
Applications/Great Plains/Servers/
Applications/Great Plains/Servers/
Applications/HeartBase/
Applications/HeartBase/
Applications/HeartBase/
Applications/HHC/
Applications/HHC/
Applications/HHC/
Applications/HHC/

I would want the result to be this:

Applications/Diabetic Registry/
Applications/Great Plains/
Applications/Great Plains/Servers/
Applications/HeartBase/
Applications/HHC/

I've tried using StreamReader and StreamWriter simulataneously with no
success...any other ideas?


Jan 23 '06 #2
What does "no success" mean? Are you having trouble finding the unique
values or doing a read and a write in the same loop? In either case, I'm
thinking that you could load each item into a collection that doesn't allow
duplicates -- I can't think of which one you'd want off the top of my head,
but there's probably something in the Framework that will suit -- then write
the values back out to a file.

Maybe you could post some pseudo code or describe the exact nature of your
problem.

Mitchell S. Honnert
www.UltraID3Lib.com
"soup_nazi" <bc*****@wfs-ops.org> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
I want to remove duplicate entries within a text file. So if I had
this within a text file...

Applications/Diabetic Registry/
Applications/Diabetic Registry/
Applications/Diabetic Registry/
Applications/Great Plains/
Applications/Great Plains/
Applications/Great Plains/
Applications/Great Plains/Servers/
Applications/Great Plains/Servers/
Applications/HeartBase/
Applications/HeartBase/
Applications/HeartBase/
Applications/HHC/
Applications/HHC/
Applications/HHC/
Applications/HHC/

I would want the result to be this:

Applications/Diabetic Registry/
Applications/Great Plains/
Applications/Great Plains/Servers/
Applications/HeartBase/
Applications/HHC/

I've tried using StreamReader and StreamWriter simulataneously with no
success...any other ideas?

Jan 23 '06 #3
Soup_nazi,

Do you have an explenation for the Nick you are using.

This is an International newsgoup. For some people in the world can the nick
you use be quiet shocking.

So please if you don't have a good explanation, change it.

Cor
Jan 23 '06 #4

"Cor Ligthert [MVP]" <no************@planet.nl> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Soup_nazi,

Do you have an explenation for the Nick you are using.

This is an International newsgoup. For some people in the world can the nick you use be quiet shocking.

So please if you don't have a good explanation, change it.

Cor


Cor,

I believe his nickname is based on a character from a comedy television show
called Seinfeld.
This character had a shop where they sold very good soup. However, he had a
very unpleasant personality and due to the way he behaved, the other
characters on the show gave him the nickname Soup Nazi. Within the context
of this show, it is very funny.

However, taken out of context and without knowledge of the show, it very
well could be shocking and/or offensive to others. From my point of view, I
believe I can safely say that the poster has absolutely no intention of
offending anyone. But since this is an International newsgroup, they might
want to reconsider their chosen nickname.

Gerald
Jan 23 '06 #5
I would agree, have seen this show but has no place here.

"Gerald Hernandez" <Cablewizard@sp*********@Yahoo.com> wrote in message
news:OY*************@TK2MSFTNGP14.phx.gbl...

"Cor Ligthert [MVP]" <no************@planet.nl> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Soup_nazi,

Do you have an explenation for the Nick you are using.

This is an International newsgoup. For some people in the world can the

nick
you use be quiet shocking.

So please if you don't have a good explanation, change it.

Cor


Cor,

I believe his nickname is based on a character from a comedy television
show
called Seinfeld.
This character had a shop where they sold very good soup. However, he had
a
very unpleasant personality and due to the way he behaved, the other
characters on the show gave him the nickname Soup Nazi. Within the context
of this show, it is very funny.

However, taken out of context and without knowledge of the show, it very
well could be shocking and/or offensive to others. From my point of view,
I
believe I can safely say that the poster has absolutely no intention of
offending anyone. But since this is an International newsgroup, they might
want to reconsider their chosen nickname.

Gerald

Jan 23 '06 #6
apologize for offending anyone...this was referring to a Seinfeld
character.

Jan 25 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

33
by: Jason Heyes | last post by:
I would like to modify the contents of a file, replacing all occurances of one string with another. I wrote these functions: bool read_file(std::string name, std::string &s); bool...
5
by: jrmsmo | last post by:
Hi I have a document as follows: <?xml version="1.0"?> <metadata xml:lang="en"> </metadata> I want to change the document so it looks as follows: <?xml version="1.0"?> <metadata...
1
by: Max Khitrov | last post by:
Hello everyone, I'm working on a VS .NET add-in that will allow developers to use Subversion software from within the IDE (much like Source Safe). Ideally, I would like for my plug-in to be able...
8
by: vadim | last post by:
Hi, Is there a .Net control available that allows to write into web.config file appsettings section? The idea is to create encrypted user name and password for database connection and then...
2
by: Randall Powell | last post by:
I am in the process of developing a Windows Service which will: (1) monitor multiple network shares; (2) marshal text file transfers into an SQL Server 2000 instance; and (3) provide messaging...
2
by: rk | last post by:
I have the following library.xml file coming from a system, this can't be modified. ____________________________________________________________________________ <?xml version="1.0"...
24
by: allpervasive | last post by:
hi all, this is reddy, a beginner to c lang,,here i have some problems in reading and modifying the contents of a file,, hope you can help to solve this problem. Here i attach the file to be...
1
ganesanji
by: ganesanji | last post by:
hi to all, I am new to php. I have to edit a text file using php. I saw the file system concepts modes. My problem is I want to change a particular text or word in a text file. How to...
1
by: Joe Cool | last post by:
I am attempting to add a function to an application I am working on to modify the JPEG Comment in a Jpeg image file. I can retrieve the JPEG Comment with no problem. The problem is modifying it....
5
by: IUnknown | last post by:
Ok, we are all aware of the situation where modifying the folder structure (adding files, folders, deleting files, etc) will result in ASP.NET triggering a recompilation/restart of the application....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.