473,385 Members | 1,829 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.

Reading text data to double crlf

I have an application that is reading data from text files to the first
occurrence of a double crlf. I have this working using streamreader
and using readline.

However, I am hitting 500+ files at a time and this is a bit slow.

I was thinking of testing this using FileStream or something similar,
but I am not sure how to detect the occurrence of crlf crlf?

Thoughts?
Amy

Apr 27 '06 #1
9 2767
am**@paxemail.com wrote:
I have an application that is reading data from text files to the first
occurrence of a double crlf. I have this working using streamreader
and using readline.

However, I am hitting 500+ files at a time and this is a bit slow.

I was thinking of testing this using FileStream or something similar,
but I am not sure how to detect the occurrence of crlf crlf?

Thoughts?
Amy

In the studio there is a configuration setting. Perhaps that is accessible
elsewhere?
Apr 27 '06 #2
It's doubtful switch to FileStream will make it any faster.
StreamReader, when constructed using a file name, just creates a
FileStream internally. Your test would be just duplicating
StreamReader.

How are you reading it now (using streamreader & readline)?

Apr 27 '06 #3
Hi Amy,

A couple of questions first, if I may:

1. Are these files always using the same encoding (Unicode, UTF8, ASCII,
etc)? It makes a difference as you can handle different encodings in
different ways. For example, ASCII is always 1 byte per character, whereas
Unicode is always 2 bytes per character, and needs a bit more effort to
read.

2. What is the expected (and projected) maximum size of any of these files?
You say that your app is processing 500+ at a time, but not what the maximum
size of any of these files is. If the files are small enough, you can read
each file all at once, rather than using ReadLine. Then you can simply
search the resulting string for "\r\n\r\n".

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

Hard work is a medication for which
there is no placebo.

<am**@paxemail.com> wrote in message
news:11**********************@j33g2000cwa.googlegr oups.com...
I have an application that is reading data from text files to the first
occurrence of a double crlf. I have this working using streamreader
and using readline.

However, I am hitting 500+ files at a time and this is a bit slow.

I was thinking of testing this using FileStream or something similar,
but I am not sure how to detect the occurrence of crlf crlf?

Thoughts?
Amy

Apr 27 '06 #4

ja**********@gmail.com wrote:
It's doubtful switch to FileStream will make it any faster.
StreamReader, when constructed using a file name, just creates a
FileStream internally. Your test would be just duplicating
StreamReader.

How are you reading it now (using streamreader & readline)?


Yes, streamreader and readline.

It seems the file reading and parsing is fast. I beleive my major
delay is the listview being built.

Amy

Apr 28 '06 #5
1.) No, the encoding could be different.
2.) File size is random. Most are less < 20k, some could be as large
as 10mb.

Currently I am going line by line and stopping at the second \r\n\.

It seems my issue is not the reading of the files, but the listview
being created. It takes several seconds (5-10) to add about 1000
entries into a 6 column listview. Unfortuantly it still happens even
when using BeginUpdate and EndUpdate. Are there any other listview
tricks?

Amy

Apr 28 '06 #6
<am**@paxemail.com> wrote:
1.) No, the encoding could be different.
2.) File size is random. Most are less < 20k, some could be as large
as 10mb.

Currently I am going line by line and stopping at the second \r\n\.

It seems my issue is not the reading of the files, but the listview
being created. It takes several seconds (5-10) to add about 1000
entries into a 6 column listview. Unfortuantly it still happens even
when using BeginUpdate and EndUpdate. Are there any other listview
tricks?


You should read the file in another thread and update the UI using
BeginInvoke.

See http://www.pobox.com/~skeet/csharp/t...winforms.shtml

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Apr 28 '06 #7
>> > How are you reading it now (using streamreader & readline)?
Yes, streamreader and readline.


That wasn't intended as a yes/no question.

Rephrasing: "Your current method (the one that uses streamreader &
readline), what is it?"

However, your next statement would make that irrelevant.

Apr 28 '06 #8
Thanks Jon,

I am currently going this avenue. I am using .Net 2.0 and seen they
now have a BackgroundWorker. Have you used this class yet?

Amy.

Jon wrote:
<am**@paxemail.com> wrote:
1.) No, the encoding could be different.
2.) File size is random. Most are less < 20k, some could be as large
as 10mb.

Currently I am going line by line and stopping at the second \r\n\.

It seems my issue is not the reading of the files, but the listview
being created. It takes several seconds (5-10) to add about 1000
entries into a 6 column listview. Unfortuantly it still happens even
when using BeginUpdate and EndUpdate. Are there any other listview
tricks?


You should read the file in another thread and update the UI using
BeginInvoke.

See http://www.pobox.com/~skeet/csharp/t...winforms.shtml

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too


Apr 28 '06 #9
<am**@paxemail.com> wrote:
I am currently going this avenue. I am using .Net 2.0 and seen they
now have a BackgroundWorker. Have you used this class yet?


I haven't used it much, but that would do the trick, certainly. You'd
still need to be careful not to manipulate the UI directly from the
wrong thread. Read the docs carefully and you should be okay.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Apr 28 '06 #10

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

Similar topics

6
by: Suresh Kumaran | last post by:
Hi All, Does anybody know the sytax in VB.NET to write the contents of a multiline text box to a text file? Appreciate help. Suresh
14
by: Job Lot | last post by:
I have tab delimited text file which gets populated on daily basis via automated process. New entry is written at the bottom. I need to create a utility which makes a copy of this file with 10 most...
4
by: MLH | last post by:
It has been mentioned that a ghosted machine or a machine linked by cable modem and USB may result in my reading a MAC address other than one burned onto a NIC in the machine. That being the case,...
1
by: Peter | last post by:
I have written a small terminal app that reads and writes to the serial port. In particular as the data is read from the serial port it is appended to the rich text box. The problem I am...
2
by: Fred | last post by:
I have a text file that has records in it 801 characters long with | as a separator between fields in the records (no CRLF between fields). I know I can use the split method to separate out the...
3
by: Alex Clark | last post by:
Hi All, I'm having some problems reading a network stream. I'm writing a lightweight POP client to handle a very specific task, but I keep unexpectedly reaching the end of the datastream when...
2
by: Antonio Tirado | last post by:
(ASP.NET c# Question) Hi, I have this odd problem: I receive a CSV File through file upload. Using an OleDB.Datareader i read each row of the file and insert it into SQL. The problem is...
8
by: MLH | last post by:
Am trying to import 20,000+ lines of text in a file FTP'd from a UNIX platform to windows via FTP session in a DOS box. About 2000 records have multiple lines in them separated by CRLF's. ...
4
by: Rock | last post by:
Hello, I am going bananas trying to get text breaks and empty lines into this text which is sent in an email. I have tried "'s and \n and r\n\ but the text in the email still wraps and also I...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.