Parsing a text file

Puppybreath

New member
Joined
Jun 13, 2005
Messages
4
Programming Experience
Beginner
I am a newbie trying to parse a variable length text file with field identifiers and then put it back together so it becomes a fixed length file. I have a REXX script that I wrote to do this but think it will run much faster using VB.

The format of the file is:

00001(01)12345(05)54321(19)000.99(13)Description
00002(05)6789(06)Data(13)Longer description of item(123)new field

where the first 5 digits are the line number, the field identifier is between parentheses, and the data for each field follows the field id. So field number 5 has a value of 54321 in the first record and a value of 6789 in the second record. The field ids do not have to be in any order and each line may or may not have the same field ids.

I need to read through the file and find all of the field ids and the longest length of field data and then rebuild the file line-by-line filling in whatever data is present in fields for that line and also adding missing field ids with space filled lengths. So using the example above the final outcome of line 1 would be:

00001(01)12345(05)54321(06)Data(13) Description(19)000.99(123)

The logic I used in my script was that the field id was the value stored in
( "(" + 1 through ")" - 1 ). The data was stored in ( ")" + 1 through "(" - 1)

I've looked at examples of delimited file parsing but don't understand how to go through each line and store the values found in VB.

Ant ideas on how to accomplish this?
 
Back
Top