473,395 Members | 1,931 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.

Reading x characters from a file and parsing it.

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 data once I've read it in. But
how can I get the data in. It seems like the only thing I can do is read it
in as a byte/char array and then concatenate the values to make a string.
Nothing that returns a string seems to be able to let me specify how much
data to read.

Any suggestions would be greatly appreciated.
Nov 21 '05 #1
2 1061
Hi,

The code below should put the 801 charachters into a string for you. Don't
forget to import System.IO.

Dim fs As New FileStream(mstrFilePath, FileMode.Open, FileAccess.Read)
Dim sReader As New StreamReader(fs)
Dim arrChar() As Char
Dim strData As String
sreader.Read(arrChar, (801 * (intRecordNumber - 1), 801)
strData = arrChar

Good luck! Ken.

--
Ken Dopierala Jr.
For great ASP.Net web hosting try:
http://www.webhost4life.com/default.asp?refid=Spinlight
If you sign up under me and need help, email me.

"Fred" <Fr**@NoWhere.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
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 data once I've read it in. But how can I get the data in. It seems like the only thing I can do is read it in as a byte/char array and then concatenate the values to make a string.
Nothing that returns a string seems to be able to let me specify how much
data to read.

Any suggestions would be greatly appreciated.

Nov 21 '05 #2
Fred,

When you not are looking for the method from Ken, than you probably can use
the readline method it reads everytime a line untill the crlf

http://msdn.microsoft.com/library/de...dLineTopic.asp

I hope this helps?

Cor

"Fred" <Fr**@NoWhere.com> .
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 data once I've read it in. But
how can I get the data in. It seems like the only thing I can do is read it
in as a byte/char array and then concatenate the values to make a string.
Nothing that returns a string seems to be able to let me specify how much
data to read.

Any suggestions would be greatly appreciated.

Nov 21 '05 #3

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

Similar topics

7
by: Keith Dewell | last post by:
Greetings! My current job has brought me back to working in C++ which I haven't used since school days. The solution to my problem may be trivial but I have struggled with it for the last two...
12
by: AMT2K5 | last post by:
Hello. I have a file (for a school assignment) with the following format and delimiter format. Each record in the file has the following format: 123423454567987,29873,James,Harry,St....
6
by: dough | last post by:
Heres a snippet of my code. I am trying to dynamically allocate memory for reading in strings from a file. FILE *f; /* file to read */ char *s; ...
11
by: .Net Sports | last post by:
In VB.net, I'm trying to do a couple of things in a couple of different blocks of code. I need to take the first 25 characters of a text file, then append at the end some ellipses and a MORE link...
2
by: Jean-Marie Vaneskahian | last post by:
Reading - Parsing Records From An LDAP LDIF File In .Net? I am in need of a .Net class that will allow for the parsing of a LDAP LDIF file. An LDIF file is the standard format for representing...
1
by: syhzaidi | last post by:
How can we do Parsing of Hexdecimel in C# reading string from stream file for eg.. i have a file like.......... 0f 2f 12 2d 3a.......in hexa decimal save in a file.txt and i m reading it from...
3
by: =?ISO-8859-1?Q?Fabian_L=F3pez?= | last post by:
Hi, I am parsing an XML file that includes chineses characters, like ^ uuࢲDZw.Lﳲǐ or إ... The problem is that I get an error like: UnicodeEncodeerror:'charmap' codec...
4
by: Mastastealth | last post by:
I'm trying to create a program to read a certain binary format. I have the format's spec which goes something like: First 6 bytes: String Next 4 bytes: 3 digit number and a blank byte --- Next...
2
by: Derik | last post by:
I've got a XML file I read using a file_get_contents and turn into a simpleXML node every time index.php loads. I suspect this is causing a noticeable lag in my page-execution time. (Or the...
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
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.