• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 658
  • Last Modified:

C# Read Large ASCII-based Data Files one row at a time.

I have a sequential file, where a series of numbers, 1 per row, are about 250 digits long.

Each file has over 60,000 rows.  Some has over 120,000 rows.

Each row will look like this:
01234567889901397819837490187341908734190837419083741902837491087583458934  (this is a string).

What I need to do is read the file one row at a time, without overloading memory and processing power.  I will be processing the whole file at once.

I have the script to do with what it needs to do once I have it, but I need the best way on reading the file one row at a time without overloading memory.

I plan on splitting the row up into parts, then saving the parts into various tables and spreadsheets.

Any help would be greatly appreciated, thanks.
Evan Cutler
Evan Cutler
1 Solution
Mike TomlinsonMiddle School Assistant TeacherCommented:
Standard StreamReader will do it, allowing you to read only one line at a time:
            string line;
            string FileName = @"c:\some path\folder\file.txt";
            StreamReader SR = new StreamReader(FileName);
            while (!SR.EndOfStream)
                line = SR.ReadLine();

                // ... do something with "line" in here...


Open in new window

Evan CutlerAuthor Commented:
Thank you very much...
this worked great.

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now