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 509381
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T07:00:18+00:00 2026-05-13T07:00:18+00:00

Here’s the scenario. I have a text file(alpha), single column, with a bunch of

  • 0

Here’s the scenario.

I have a text file(alpha), single column, with a bunch of items.

My 2nd file is a csv(delta) with 4 columns.

I have to have the alpha compare again the delta and create a new file (omega) in which anything that alpha matched delta, it would export only the first two columns from delta into a new .txt file.

Example:
(Alpha)
BeginID

(delta):
BeginID,Muchmore,Info,Exists

(Omega):
BeginID,Muchmore

This document will probably have 10k lines it in. Thanks for the help!

  • 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-13T07:00:18+00:00Added an answer on May 13, 2026 at 7:00 am

    Here’s a rough cut way of doing the task you need:

    using System;
    using System.Collections.Generic;
    using System.IO;
    using System.Text;
    
    namespace ConsoleApplication1
    {
        class Program
        {
            static void Main(string[] args)
            {
                string alphaFilePath = @"C:\Documents and Settings\Jason\My Documents\Visual Studio 2008\Projects\Compte Two Files\Compte Two Files\ExternalFiles\Alpha.txt";
    
                List<string> alphaFileContent = new List<string>();
    
                using (FileStream fs = new FileStream(alphaFilePath, FileMode.Open))
                using(StreamReader rdr = new StreamReader(fs))
                {
                    while(!rdr.EndOfStream)
                    {
                        alphaFileContent.Add(rdr.ReadLine());
                    }
                }
    
                string betaFilePath = @"C:\Beta.csv";
    
                StringBuilder sb = new StringBuilder();
    
    
                using (FileStream fs = new FileStream(betaFilePath, FileMode.Open))
                using (StreamReader rdr = new StreamReader(fs))
                {
                    while(! rdr.EndOfStream)
                    {
                        string[] betaFileLine = rdr.ReadLine().Split(Convert.ToChar(","));
    
                        if (alphaFileContent.Contains(betaFileLine[0]))
                        {
                            sb.AppendLine(String.Format("{0}, {1}", betaFileLine[0], betaFileLine[1]));
                        }
                    }
    
    
                   }
    
    using (FileStream fs = new FileStream(@"C:\Omega.txt", FileMode.Create))
                using (StreamWriter writer = new StreamWriter(fs))
                {
                    writer.Write(sb.ToString());
                }
    
                    Console.WriteLine(sb.ToString());
                }
            }
        }
    

    Basically it reads a txt file, puts the contents in a list. Then it reads a csv file (assuming no columns) and matches the values to create a StringBuilder. In your code, substitute the StringBuilder with creating a new txt file.

    EDIT: If you wish to have the code run in a button click, then put it in the button click handler (or a new routine and call that):

    public void ButtonClick (Object sender, EventArgs e)
    {
    string alphaFilePath = @"C:\Documents and Settings\Jason\My Documents\Visual Studio 2008\Projects\Compte Two Files\Compte Two Files\ExternalFiles\Alpha.txt";
    
                List<string> alphaFileContent = new List<string>();
    
                using (FileStream fs = new FileStream(alphaFilePath, FileMode.Open))
                using(StreamReader rdr = new StreamReader(fs))
                {
                    while(!rdr.EndOfStream)
                    {
                        alphaFileContent.Add(rdr.ReadLine());
                    }
                }
    
                string betaFilePath = @"C:\Beta.csv";
    
                StringBuilder sb = new StringBuilder();
    
    
                using (FileStream fs = new FileStream(betaFilePath, FileMode.Open))
                using (StreamReader rdr = new StreamReader(fs))
                {
                    while(! rdr.EndOfStream)
                    {
                        string[] betaFileLine = rdr.ReadLine().Split(Convert.ToChar(","));
    
                        if (alphaFileContent.Contains(betaFileLine[0]))
                        {
                            sb.AppendLine(String.Format("{0}, {1}", betaFileLine[0], betaFileLine[1]));
                        }
                    }
                }
    
    using (FileStream fs = new FileStream(@"C:\Omega.txt", FileMode.Create))
            using (StreamWriter writer = new StreamWriter(fs))
            {
                writer.Write(sb.ToString());
            }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

here is the scenario, I have text box, if I type few characters in
Here is the scenario... I have a a checkbox next to each field that
Here is my scenario: I've got a database, where 2 columns are interesting for
I have a log file in the format below as you can see each
How can I access the key of a non-associate array? Here's my scenario, I
I am trying to search for any string that contains ; in a column
I'm supposed to do the fallowing: 1) read a huge (700MB ~ 10 million
I would like to invoke a simple method (no arguments, returns void) from within
If you are talking about btrees, I wouldn't imagine that the additional overhead of
As of XSLT 2.0, as far as I know (correct me if I’m wrong),

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.