Re: variable size record length file parsing

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance




I need help parsing a file that will have variable sized record lengths.

It depends on the format of the file and how the records are separated.

Each line is between 280-320 chars long and ends with an "X" then a
CR/LF. Here is an example of a few lines from the file:

You pretty much only have two options: using Line Input and working with a
line at a time or reading the file into a byte array (completely or in
chunks) and searching for CRLF yourself, which is pretty much what Line
Input is doing.

Users love delimited, non-fixed-width files because they're easy to work
with for them. As a programmer, I despise them. Fixed-width files rock.

I guess a third option would be to open the file in line input mode and dump
all of the recordsizes into an array and close the file, then re-open it in
binary and use those for my record sizes. I really like using the UDT with
fixed string sizes because I have a document that tells me exactly what they
are. So it's much easier to do it that way and it's fast too.

If anyone else wants to chime it, I'm listening.

Matt


.