I’m asking for the wisdom of the stackoverflow community. I’m working on a test given to me. I’m using C#, I need to read in a text file that contains commercial flight information. This text file is as follows:
1 AA2401 F7 A4 Y7 B7 M7 H7 K7 /DFW A LAX 4 0715 0836 E0.M80 9 3:21
2 AA2421 F7 A1 Y7 B7 M7 H7 K7 DFWLAX 4 1106 1215 E0.777 7 3:09
3UA:US6352 B9 M9 H9 K0 /DFW 1 LAX 1200 1448 E0.733 1:48
4 AA2407 F7 A6 Y7 B7 M7 H7 K7 /DFW A LAX 4 0820 0936 E0.757 6 3:16 *
5 UA 499 F7 Y9 B9 M9 H9 Q9 V9 /DFW B LAX 7 0840 0959 E0.319 4 3:19
6 UA 448 M9 H9 Q9 V9 /DFW 1 LAX 1200 1448 E0.733 8 1:48 /
7UA:US6376 B9 M9 H9 K9 /DFW 1 LAX 1315 1603 E0.735 1:48
8 AA2883 F7 A6 Y7 B7 M7 H7 K7 DFWLAX 4 1215 1328 E0.757 9 3:13
9UA:US6440 B9 M9 H9 K9 /DFW 1 LAX 1445 1732 E0.735 1:47 /E
10 UA1584 M9 H9 Q9 V9 /DFW LAX 1445 1732 E0.735 9 1:47
11 UA1082 M9 H9 Q9 V9 /DFW LAX 1450 1735 E0.735 8 1:45
12 UA 662 M9 H9 Q9 V9 /DFW 1 LAX 1315 1603+1E0.735 N 1:48 /E
13 DL 333 F9 A9 Y9 B9 M9 H9 Q9 /DFW E LAX 5 0930 1046 E0/738 8 3:16
14 AA2413 F7 A7 Y7 B7 M7 H7 K7 /DFW A LAX 4 1008 1124 E0.757 8 3:16
15 DL1435 F9 A9 Y9 B9 M9 H9 Q9 DFWLAX 5 1130 1250-1E0/738 9 3:20
16UA:US6392 B9 M9 H9 K9 /DFW LAX 1450 1735 E0.735 1:45
17 F9 436 B4 Y4 K4 M4 DFW 1 LAX 1525 1810+1E0.733 1:45 *
18 HP 497 W4 B7 Q7 L7 DFW 1 LAX 1700 1943+1E0.319 N 1:43
Given this text file, the information contains the following columns:
LineNumber
Carrier
OperatingCarrier
FlightNumber
Classes
DepartureAirport
ArrivalAirport
DepartureTime
ArrivalTime
ArrivalTimeShift
Equipment
Ontime
Duration
I also given these two examples:
For Line 3:
3 LineNumber
UA Carrier
US OperatingCarrier
6352 FlightNumber
BMHK Classes
DFW DepartureAirport
LAX ArrivalAirport
1200 DepartureTime
1448 ArrivalTime
ArrivalTimeShift
733 Equipment
Ontime
1:48 Duration
For line 18:
18 LineNumber
HP Carrier
OperatingCarrier
497 FlightNumber
WBQL Classes
DFW DepartureAirport
LAX ArrivalAirport
1700 DepartureTime
1943 ArrivalTime
+1 ArrivalTimeShift
319 Equipment
N Ontime
1:43 Duration
I was also directed to make use of regular expressions. Trying to parse this has been a nightmare due to the variance in each line, especially with the spaces. I’m just looking for ideas on how to start tackling this beast. I know I can get rid of the /’s, the :’s, and the *’s.
Thanks.
Take it a step at a time. For example:
and so on.