473,395 Members | 1,649 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,395 software developers and data experts.

Read Text From Stream Then Reposition And Repeat

Thanks to all...

I need to read a block of text, operate on the read text then move to the
next text block and so on and so on from a 650MB file.

Pseudo code would be something like this:

1. Start at the beginning of the text file
2. Read in 100K of text
3. Work with the 100K of text
4. Repostion the cursor to the start of the next text block (position now
100001)
5. Read in 100K of text
6. Work with the 100K of text
7. Repostion the cursor to the start of the next text block (position now
200001)
8. Read in 100K of text
9. etc

I'm thinking that I need to use the StreamReader.Read function. Is this the
best approach? What approach will be the fastest?

Thanks very much

-- ty_92648 AT hotmail.com
Nov 16 '05 #1
2 2600
<"Garibaldi" <ty_92648 AT hotmail.com>> wrote:
Thanks to all...

I need to read a block of text, operate on the read text then move to the
next text block and so on and so on from a 650MB file.

Pseudo code would be something like this:

1. Start at the beginning of the text file
2. Read in 100K of text
3. Work with the 100K of text
4. Repostion the cursor to the start of the next text block (position now
100001)
5. Read in 100K of text
6. Work with the 100K of text
7. Repostion the cursor to the start of the next text block (position now
200001)
8. Read in 100K of text
9. etc

I'm thinking that I need to use the StreamReader.Read function. Is this the
best approach? What approach will be the fastest?


Why bother repositioning? Just read in the first 100K, then read in the
next 100K with the same StreamReader, etc.

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

If you are reading text the best way of doing it is using StreamReader
class
Now depending of what you are doing you can use two approachs
1- treat the reading as lines using ReadLine() and keeping them in a
string[]
2- treat the text as a group of char and reading then on a char[] as you
proposed. if you dont need to keep track of lines this is the best way

Btw, you don;t need to reposition the stream, unless that you need to write
back the modified data (which is entirely another matter ).

Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Garibaldi" <ty_92648 AT hotmail.com> wrote in message
news:eu**************@TK2MSFTNGP10.phx.gbl...
Thanks to all...

I need to read a block of text, operate on the read text then move to the
next text block and so on and so on from a 650MB file.

Pseudo code would be something like this:

1. Start at the beginning of the text file
2. Read in 100K of text
3. Work with the 100K of text
4. Repostion the cursor to the start of the next text block (position now
100001)
5. Read in 100K of text
6. Work with the 100K of text
7. Repostion the cursor to the start of the next text block (position now
200001)
8. Read in 100K of text
9. etc

I'm thinking that I need to use the StreamReader.Read function. Is this the best approach? What approach will be the fastest?

Thanks very much

-- ty_92648 AT hotmail.com

Nov 16 '05 #3

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

Similar topics

1
by: Adam Knight | last post by:
I am reading a file on the fly..which contains both ASP and html. Is their anyway i can cause any ASP in this Text Stream to execute ??? AK
2
by: Garibaldi | last post by:
Thanks to all... I need to read a block of text, operate on the read text then move to the next text block and so on and so on from a 650MB file. Pseudo code would be something like this: ...
16
by: Adda | last post by:
If I cycle through the MdiChildActivate event of the parent form I can read text in a textbox on the child mdiform -- console.writeline(Me.ActiveMdiChild.Controls(1).Text) But if I have a sub...
5
by: Mika M | last post by:
Hi! I'm trying to read text file like... "Field1";"Field2";"Field3";"Field4" "ABCD";"EFGH";"1234";"20051020" "AABB";"CCDD";"2468";"20051021" "CCDD";"XXYY";"4321";"20051022" ....using OLE...
2
by: om | last post by:
hi I an new to c++ and was wondering if anyone could advise me how to read a stream coming from a http source thanks alot...
9
by: anachronic_individual | last post by:
Hi all, Is there a standard library function to insert an array of characters at a particular point in a text stream without overwriting the existing content, such that the following data in...
2
by: Jack | last post by:
Hi, I want to read a string a chars from a stream, and put it into a string. At the moment, I'm creating a buffer of a fixed size, and reading the stream of text into it. It works, but I have...
3
by: hdbbdh | last post by:
Hello everyone, I try to read a stream and save it as byte array to add it later to zip file. this is the code that I use Dim totalbytes As Byte() = Nothing Dim iBytesRead As Integer Dim...
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:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.