我需要将相应的标头值添加到每个块作为新列。
样本表:
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
预期产出:
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
答案 0 :(得分:0)
这将需要编写脚本。
您可以编写执行整个操作的脚本任务,也可以创建使用脚本组件作为源的数据流。使用filesystemobject
打开filestream
并逐行读取文件,并分析每一行以查看它是HDR,BHD,BTR还是常规数据行。将最后一个HDR值保留在局部变量中,并将其作为附加列添加到每个数据行。