Solved

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

Posted on 2008-06-22
7
316 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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

743 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now