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

  • Home
  • SEARCH
  • 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 6688575
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T05:25:08+00:00 2026-05-26T05:25:08+00:00

I have two csv files. In the first file i have a list of

  • 0

I have two csv files. In the first file i have a list of users, and in the second file i have a list of duplicate users. Im trying to remove the rows in the first file that are equal to the second file.

Heres the code i have so far:

StreamWriter sw = new StreamWriter(path3);
        StreamReader sr = new StreamReader(path2);

        string[] lines = File.ReadAllLines(path);

        foreach (string line in lines)
        {
            string user = sr.ReadLine();

            if (line != user) 
            {
                sw.WriteLine(line);

            }

File 1 example:

Modify,ABAMA3C,Allpay - Free State - HO,09072701

Modify,ABCG327,Processing Centre,09085980

File 2 Example:

Modify,ABAA323,Group HR Credit Risk & Finance

Modify,ABAB959,Channel Sales & Service,09071036

Any suggestions?

Thanks.

  • 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-26T05:25:09+00:00Added an answer on May 26, 2026 at 5:25 am

    All you’d have to do is change the following file paths in the code below and you will get a file back (file one) without the duplicate users from file 2. This code was written with the idea in mind that you want something that is easy to understand. Sure there are other more elegant solutions, but I wanted to make it as basic as possible for you:

    (Paste this in the main method of your program)

            string line;
            StreamReader sr = new StreamReader(@"C:\Users\J\Desktop\texts\First.txt");
    
            StreamReader sr2 = new StreamReader(@"C:\Users\J\Desktop\texts\Second.txt");
    
            List<String> fileOne = new List<string>();
            List<String> fileTwo = new List<string>();
    
            while (sr.Peek() >= 0)
            {
                line = sr.ReadLine();
                if(line != "")
                {
                    fileOne.Add(line);
                }
            }
            sr.Close();
            while (sr2.Peek() >= 0)
            {
                line = sr2.ReadLine();
                if (line != "")
                {
                    fileTwo.Add(line);
                }
            }
            sr2.Close();
            var t = fileOne.Except(fileTwo);
    
            StreamWriter sw = new StreamWriter(@"C:\Users\justin\Desktop\texts\First.txt");
    
            foreach(var z in t)
            {
                sw.WriteLine(z);
            }
            sw.Flush();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two csv file. First File has date offerid clicks orders Second File
I have a list of csv files ( file1, file2, ... ) that have
I have two .csv files containing correlation matrices exported from R. One file contains
I have some code that creates a CSV file. The order of the rows
I have a CSV file that I'm totaling up two ways: one using Excel
I have two DataTables, A and B , produced from CSV files. I need
I need to develop an application where two csv files are compared. The first
I have a incomplete csv file that needs to be accurately updated, so there
I am trying to create a CSV file. I have done this. I have
I have two csv files: csv1 <- data.frame(y=c(classA, classB, classA, classB, classA, classC), DBID=c(d1,

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.