views:

44

answers:

2

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

Here is a reduced text file.

link text

+2  A: 

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.

jball
+1 great link! I have always hardcoded stuff like this.
CResults
However, not convinced by TextFieldParser as the format of the file (including the section he is interested in) changes throughout and cannot be classed as a standard fixed-width file.
CResults
True, I think you could get it to work by selectively sections though. Your `.instr()` suggestion seems like a good way to go if an outside library is out.
jball
+1  A: 

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

CResults