Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3756488
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T09:51:35+00:00 2026-05-19T09:51:35+00:00

what i want to do is de-dupe a text file (against itself) based on

  • 0

what i want to do is de-dupe a text file (against itself) based on the split. Once the de-dupe has been complete write out to a new file and keep the first result. So a basic example is. I guess the question is how do you de dupe a text file in C# based on a string split.

File 1:
Apple|Turnip3234
Apple|Tunip22
Fox|dsa34
Turtle|3423
Hamster|d34
Fox|sdw2

Result:
Apple|Turnip3234
Fox|dsa34
Turtle|3423
Hamster|d34

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T09:51:36+00:00Added an answer on May 19, 2026 at 9:51 am
    string inputFile; // = ...
    string outputFile; // = ...
    HashSet<string> keys = new HashSet<string>();
    
    using (StreamReader reader = new StreamReader(inputFile))
    using (StreamWriter writer = new StreamWriter(outputFile))
    {
        string line = reader.ReadLine();
        while (line != null)
        {
            string candidate = line.Split('|')[0];
            if (keys.Add(candidate))
                writer.WriteLine(line);
    
            line = reader.ReadLine();
        } 
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Want to find one and modify that to read, write file on mongoDB gridfs
Want to update page after jeditable (using gem on_the_spot) has been updated. Below works
Want to send the text from my current vb application to the Active Window
want to create a temporary table that has an auto_increment field plus a field
Want to build up a csv file, call up the default email app and
Want to save the current state of my canvas as a picture, jpg file,
Edit: This is not a dupe of my last question as I didn't want
I have successfully made a script that filters out duplicate lines in a file
Want to show icon for settings UIBarButtonItem on UIToolbar than text button UIBarButtonItem *settingsButton
I have a web service I'm calling that does a dupe check based on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.