user38349
user38349

Reputation: 3025

How Do You Parse Column Data?

I am trying to parse a file generated by LGA Tracon that lists the position data for aircraft over a given time frame. The data of interest starts with TRACKING DATA and ends with SST and there are thousands of entries per file. The system generating the file, Common ARTS, is very rigid in its formatting and we can expect the column spacing to be consistent. Any help would be greatly appreciated.

Thanks,

Here is an image to preserve the exact formatting alt text
(source: schedulebook.com)

Here is a reduced text file.

link text

Upvotes: 0

Views: 206

Answers (2)

CResults
CResults

Reputation: 5105

If you choose to ignore jball's suggestion of FileHelpers (which looks great) I would suggest reading the file line by line until you identify a line starting with TRACKING DATA

Then pull the next 11 lines into an array and start manipulating with .instr( )

You may find this solution is faster than using an additional library as your hand-built code will be tailored directly to the problem in hand. Not having used FileHelpers I don't know of its speed overhead.

I have written a lot of file parsing before in the past (funnily enough also with travel based text files) and found it pretty fast/efficient

Upvotes: 1

jball
jball

Reputation: 25014

There are many ways to solve this problem, but free libraries like FileHelpers have solved this. They even have a Quick Start for Fixed Length files with VB code already.

If you're unable to use an outside library, you can start with the built in .NET TextFieldParser. You'll need to do a lot more work with that than you would with FileHelpers, but it handles the fixed-width part very well.

Upvotes: 2

Related Questions