Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

How to open a huge text file and count the lines?

Posted on 2008-06-22
7
321 Views
Last Modified: 2013-11-07
I am using ASP.NET in VB.
I have some huge text file which the size is normally 950MB to 1GB. I need to do the counting of lines for my text file. And this huge file is located at my local computer.
May I know is there any solution that I can do the count of lines for my text file?
0
Comment
Question by:runbird
7 Comments
 
LVL 3

Expert Comment

by:dshroutait
ID: 21843206
You could use Notepad++
0
 
LVL 2

Expert Comment

by:ayus80
ID: 21843222
0
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 21843223
have you tried to open it with Visual Studio?
0
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 21843234
or you can use some kind of line counter, you don't have to load the file into memory:
 http://www.codeproject.com/KB/files/SourceCodeLineCounter.aspx
0
 
LVL 2

Accepted Solution

by:
martin_kongen earned 500 total points
ID: 21892602
You want to count the lines automatically, when a user requests the web page, right? You should probably open the file using System.IO.StreamReader, StringReader or TextReader. (I can never remember which one to use).

Then you can use that stream and loop through every character in the file. Your counter starts at 1, and you add 1 every time you encounter the newline character (probably called vbLF in visual basic). When done, the counter has the number of lines and you can close the file.
0

Featured Post

How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
JSON  parse help 7 40
asp.net input html code have it display the content 2 22
how to just get time from a date 6 33
Get month and date in a format 4 32
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question