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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T22:07:50+00:00 2026-05-26T22:07:50+00:00

I have a 150mb file. Each line is made up of the same format

  • 0

I have a 150mb file. Each line is made up of the same format eg/

I,h,q,q,3,A,5,Q,3,[,5,Q,8,c,3,N,3,E,4,F,4,g,4,I,V,9000,0000001-100,G9999999990001800000000000001,G9999999990000001100PDNELKKMMCNELRQNWJ010, , , , , , ,D,Z,

I have a Dictionary<string, List<string>>

It is populated by opening the file, reading each line, taking elements from the line and adding it to the dictionary, then the file is closed.

StreamReader s = File.OpenText(file);
 string lineData = null;
 while ((lineData = s.ReadLine()) != null)
 {
   var elements = lineData.Split(',');
   var compareElements = elements.Take(24);
   FileData.Add(elements[27], new List<string>(compareElements));

  }
  s.Close();

Using the method in this answer I calculated my dictionary to be 600mb. That’s 4 times what the file is.

Does that sound correct?

  • 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-26T22:07:51+00:00Added an answer on May 26, 2026 at 10:07 pm

    Most of these entities take only a single character, yet you are storing them as strings. The reference pointer to those string alone is going to take at least twice as much space (in case of UTF8 likely 4-8 times as much). Then there is the overhead of keeping a hash table structured for the dictionary.

    The List<> in itself should be really efficient storage wise (it uses an array internally)

    Room for improvement:

    • you could use List<char> or char[] instead of List<string> if you know that the fields will fit
    • you could use struct Field { char a,b/*,...*/; } and List instead of List if you need more than 1 character per field
    • You could forgo the eager field extraction [<– recommended]:

       var dict = File.ReadAllLines(file)
            .ToDictionary(line => line.Split(',')[27]);
      

      This gives you the opportunity to access the compareElements on demand:

       string[] compareElements = dicts["key27"].Split(',')/*.Take(24).ToArray()*/;
      

      This is a classic example of runtime/storage cost trade-off

    Edit an obvious hybrid would be:

    struct AllCompareElements
    {
         public char field1, field2, ... field24;
         // perhaps:
         public char[2] field13; // for the exceptional field that is longer than 1 character
    }
    

    Happily employ Resharper to implement Equals, GetHashCode, IEquatable<AllCompareElements>, IComparable<AllCompareElements>

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

Sidebar

Related Questions

I have 20 large CSV (100-150MB each) files i would like to load in
I have changed the upload_max_filesize to 150MB in the php.ini file. but http://localhost/info.php shows
I have a ASCII file where every line contains a record of variable length.
I have one server which has nothing but xls log files. Each file is
I have a big text file (about 100MB) and each lines are separated by
I have a 100Mb file with roughly 10million lines that I need to parse
I have a large 100mb file which I would like to perform about 5000
I have an app that reads a huge text file (about more than 100MB)
Have deployed numerous report parts which reference the same view however one of them
I have a program that loads a file (anywhere from 10MB to 5GB) a

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.