473,385 Members | 1,569 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

1 GB text file

Hello,

I want to read an 1GB text file in parts of 100 lines. When I use just a
simple stram/filereader, I think it reads the whole file, wich results in a
hanging machine. Is there a way to do it in blocks? For debugging this is a
lot easyer.

Patrick
Nov 16 '05 #1
5 3916
Patrick Sannes wrote:

Hello,

I want to read an 1GB text file in parts of 100 lines. When I use just a
simple stram/filereader, I think it reads the whole file, wich results in a
hanging machine. Is there a way to do it in blocks? For debugging this is a
lot easyer.

Patrick


I've used StreamReader.ReadLine() on 100+ MB files just fine, and it didn't
read the whole file, just that line.
Nov 16 '05 #2
>>
Hello,

I want to read an 1GB text file in parts of 100 lines. When I use just a
simple stram/filereader, I think it reads the whole file, wich results in
a
hanging machine. Is there a way to do it in blocks? For debugging this is
a
lot easyer.

Patrick


I've used StreamReader.ReadLine() on 100+ MB files just fine, and it
didn't
read the whole file, just that line.


You tried something like:
StreamReader sr = File.OpenText(filename);
String input = sr.ReadLine();

??
Nov 16 '05 #3
Patrick Sannes <pa*****@nospam.penan.nospam.nl> wrote:
I want to read an 1GB text file in parts of 100 lines. When I use just a
simple stram/filereader, I think it reads the whole file, wich results in a
hanging machine. Is there a way to do it in blocks? For debugging this is a
lot easyer.


How are you reading it? If you use TextReader.ReadToEnd it will indeed
read the whole file. If you just use ReadLine it will only read a line
at a time.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #4
Patrick Sannes wrote:

Hello,

I want to read an 1GB text file in parts of 100 lines. When I use just a
simple stram/filereader, I think it reads the whole file, wich results in
a
hanging machine. Is there a way to do it in blocks? For debugging this is
a
lot easyer.

Patrick


I've used StreamReader.ReadLine() on 100+ MB files just fine, and it
didn't
read the whole file, just that line.


You tried something like:
StreamReader sr = File.OpenText(filename);
String input = sr.ReadLine();

??


Yep, just like that.
Nov 16 '05 #5
I tried it and it works... Thanks

"Bret Pehrson" <br**@classicade.com> schreef in bericht
news:41***************@classicade.com...
Patrick Sannes wrote:
>>
>> Hello,
>>
>> I want to read an 1GB text file in parts of 100 lines. When I use just
>> a
>> simple stram/filereader, I think it reads the whole file, wich results
>> in
>> a
>> hanging machine. Is there a way to do it in blocks? For debugging this
>> is
>> a
>> lot easyer.
>>
>> Patrick
>
> I've used StreamReader.ReadLine() on 100+ MB files just fine, and it
> didn't
> read the whole file, just that line.


You tried something like:
StreamReader sr = File.OpenText(filename);
String input = sr.ReadLine();

??


Yep, just like that.

Nov 16 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Rigga | last post by:
Hi, I am new to Python and need to parse a text file and cut parts out i.e. say the text file contained 5 rows of text: line 1 of the text file line 2 of the text file line 3 of the text...
3
by: Krish | last post by:
I have requirement, that i get one big chunk of text file. This text file will have has information, that on finding "****End of Information****", i have to split them individual text file with our...
7
by: Chris | last post by:
Hi I can use a text file as a datasource but am unable to get the datatable to see the text file as having multiple columns. Everything gets put into the first column in the datatable. Sample of...
0
by: Yunus's Group | last post by:
Yunus's Group May 23, 3:36 pm show options Newsgroups: microsoft.public.dotnet.languages.vb From: "Yunus's Group" <yunusasm...@gmail.com> - Find messages by this author Date: 23 May 2005...
4
by: AHP | last post by:
Hi, I'm using Visual Studio 2005. I am developing a web application that uses the FileUpload control to upload text files to a directory on a webserver. This works fine. However, for me to be...
4
by: Andyza | last post by:
I'm using FileSystemObject to open and write to a tab delimited text file. First, I connect to a database and select some data. Then I create the text file and insert each record in the text...
3
by: R. P. | last post by:
Subject: XSLT to transform a flat XML file into a structured text file I have an XML file that lists the PDF file segment names and titles of a larger document and looks something like this: ...
1
by: Osoccer | last post by:
...to a different folder and in the relocated file concatenates all of the lines in one long string with a space between each line element. Here is a fuller statement of the problem: I need a...
6
Atran
by: Atran | last post by:
Hello: In this article: You will learn to Write or Read A Text File. Let's Begin: First Create a new project (ConsoleApp or WinApp). And Make sure your program uses these namespaces: using...
10
by: bluemountain | last post by:
Hi there, Iam new to python forms and programming too I had a text file where i need to extract few words of data from the header(which is of 3 lines) and search for the keyword TEXT1, TEXT2,...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.