Solved

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

Posted on 2008-06-22
7
323 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
[X]
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
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

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

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

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
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…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

749 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