0
  1. I have table which consist of several header code (it always starts with HDR)
  2. Every header will have its own BHD(start) and BTR(end) tags

I Need to add corresponding header value to each block as a new column.

Sample Table:

HDR20170101
BHD0000A123J010203
0020CHETRI      || ULTRA DELUXE || 123UD || 00:20 
0300CHETRIKK02S || DELUXE       || 908UU || 03:00
0330CHETRIKK02S || DELUXE       || 908BN || 03:30
BTR0000A123J010203DHU84596
HDR20170102
BHD0000A123J010225
0400CHETRIKK02O || ORDINARY     || 908AH || 04:00 
0400CHETRIKK02S || DELUXE       || 908BN || 04:00
0500CHETRIKK02O || ORDINARY     || 908AC || 05:00
0515CHETRIKK02S || DELUXE       || 908AE || 05:15
BTR0000A123J010225DHU59658
HDR20170103
BHD0000A123J010242
0530CHETRIKK04O || ORDINARY     || 2251  || 05:30
0615CHETRIKK02S || DELUXE       || 908BC || 06:15
BTR0000A123J0100242DHU34745

Expected output :

Trip Code       || ClassOfServ  || Route || Depart || Header
0020CHETRI      || ULTRA DELUXE || 123UD || 00:20  || HDR20170101
0300CHETRIKK02S || DELUXE       || 908UU || 03:00  || HDR20170101
0330CHETRIKK02S || DELUXE       || 908BN || 03:30  || HDR20170101
0400CHETRIKK02O || ORDINARY     || 908AH || 04:00  || HDR20170102
0400CHETRIKK02S || DELUXE       || 908BN || 04:00  || HDR20170102
0500CHETRIKK02O || ORDINARY     || 908AC || 05:00  || HDR20170102
0515CHETRIKK02S || DELUXE       || 908AE || 05:15  || HDR20170102
0530CHETRIKK04O || ORDINARY     || 2251  || 05:30  || HDR20170103
0615CHETRIKK02S || DELUXE       || 908BC || 06:15  || HDR20170103
vignesh
  • 1,414
  • 5
  • 19
  • 38

1 Answers1

0

This is going to require scripting.

You can either write a script task that does the whole thing, or you can create a dataflow that uses a script component as the source. Use the filesystemobject to open a filestream and read the file line by line, and analyze each line to see if it is a HDR, BHD, BTR, or regular data row. Keep the last HDR value in a local variable and add it to each data row as an additional column.

Tab Alleman
  • 31,483
  • 7
  • 36
  • 52