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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T23:23:25+00:00 2026-05-30T23:23:25+00:00

I have a .txt file which has about 500k entries, each separated by new

  • 0

I have a .txt file which has about 500k entries, each separated by new line. The file size is about 13MB and the format of each line is the following:

SomeText<tab>Value<tab>AnotherValue<tab>

My problem is to find a certain “string” with the input from the program, from the first column in the file, and get the corresponding Value and AnotherValue from the two columns.

The first column is not sorted, but the second and third column values in the file are actually sorted. But, this sorting is of no good use to me.

The file is static and does not change. I was thinking to use the Regex.IsMatch() here but I am not sure if that’s the best approach here to go line by line.

If the lookup time would increase drastically, I could probably go for rearranging the first column (and hence un-sorting the second & third column). Any suggestions on how to implement this approach or the above approach if required?

After locating the string, how should I fetch those two column values?

EDIT
I realized that there will be quite a bit of searches in the file for atleast oe request by the user. If I have an array of values to be found, how can I return some kind of dictionary having a corresponding values of found matches?

  • 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-30T23:23:27+00:00Added an answer on May 30, 2026 at 11:23 pm

    How many times do you need to do this search?
    Is the cost of some pre-processing on startup worth it if you save time on each search?
    Is loading all the data into memory at startup feasible?
    Parse the file into objects and stick the results into a hashtable?

    I don’t think Regex will help you more than any of the standard string options. You are looking for a fixed string value, not a pattern, but I stand to be corrected on that.

    Update
    Presuming that the “SomeText” is unique, you can use a dictionary like this

    Data represents the values coming in from the file.
    MyData is a class to hold them in memory.

    public IEnumerable<string> Data = new List<string>() {
      "Text1\tValue1\tAnotherValue1\t",
      "Text2\tValue2\tAnotherValue2\t",
      "Text3\tValue3\tAnotherValue3\t",
      "Text4\tValue4\tAnotherValue4\t",
      "Text5\tValue5\tAnotherValue5\t",
      "Text6\tValue6\tAnotherValue6\t",
      "Text7\tValue7\tAnotherValue7\t",
      "Text8\tValue8\tAnotherValue8\t"
    };
    
    public class MyData {
       public String SomeText { get; set; }
       public String Value { get; set; }
       public String AnotherValue { get; set; }
    }
    
    
    [TestMethod]
    public void ParseAndFind() {
    
            var dictionary = Data.Select(line =>
            {
                var pieces = line.Split(new char[] { '\t' }, StringSplitOptions.RemoveEmptyEntries);
                return new MyData {
                    SomeText = pieces[0],
                    Value = pieces[1],
                    AnotherValue = pieces[2],
                };
            }).ToDictionary<MyData, string>(dat =>dat.SomeText);
    
            Assert.AreEqual("AnotherValue3", dictionary["Text3"].AnotherValue);
            Assert.AreEqual("Value7", dictionary["Text7"].Value);
    
    }
    

    hth,

    Alan

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a txt file which has data in the below format: int string
I'm having trouble with PHP text parsing I have a txt file which has
I have a file test.txt which has an array: array = [3,5,6,7,9,6,4,3,2,1,3,4,5,6,7,8,5,3,3,44,5,6,6,7] Now what
I have a txt file which contains data in the following format: X1 Y1
I have a txt file named BookDB.txt which has the following data. Little Prince:The
I have a CSV-like text file that has about 1000 lines. Between each record
I have a log file (.txt) which has information as below: Filename1 - A3332NCDER
I have a txt file which contains a google adsense code block and I'm
I have this file file.txt which I want to split into many smaller ones.
I have a file template.txt which contains the following: Hello ${something} I would like

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.