A
AMJEE
Guest
I have a weird (or may not be) C# requirement where I have nearly 500+ flat text files (just like ordinary letters, conversations etc... as the File file content, each files are max to max 100 lines long) and on the other hand a reference table as below (3 Columns, Zone, Stage, TopLine).
Now, we need to see each flat file for the existence of combination of Zone and Stage anywhere in the file and if it is there then add a footer line at the end of the file. For example, if a file contains, PR1 on line 4 (can be sub string not the full line = PR1, like "Noticed in PR1") and then another line, say 10th, contains STAGE_2_CONFIRM (again this can a sub-string of the entire line) then here in this file, we can conclude immediately that Footer line to be added is : ***PR1-STAGE_2_CONFIRM***
~ Hoping that I managed to explain the requirement here. Could some one kindly help?
In terms of the logical flow, I was thinking I have to have 2 loops. Outer one to fetch each file and inner one to compare if (file.Contains(Zone[j]) && file.Contains(Stage[j])) then EoL = FooterLine[j] else EoL= "" break..
Zone Stage FooterLine
PR1 STAGE_1_DETECT ***PR1-STAGE_1_DETECT***
PR1 STAGE_2_CONFIRM ***PR1-STAGE_2_CONFIRM***
SE1 STAGE_1_FORMULA ***SE1-STAGE_1_FORMULA***
SE1 STAGE_2_BUILD ***SE1-STAGE_2_BUILD***
SE2 STAGE_3_TEST ***SE2-STAGE_3_TEST***
AD1 STAGE_1_DEMO ***AD1-STAGE_1_DEMO***
AD1 STAGE_2_PUBLISH ***AD1-STAGE_2_PUBLISH***
AD2 STAGE_2_PUBLISH ***AD2-STAGE_2_PUBLISH***
Continue reading...
Now, we need to see each flat file for the existence of combination of Zone and Stage anywhere in the file and if it is there then add a footer line at the end of the file. For example, if a file contains, PR1 on line 4 (can be sub string not the full line = PR1, like "Noticed in PR1") and then another line, say 10th, contains STAGE_2_CONFIRM (again this can a sub-string of the entire line) then here in this file, we can conclude immediately that Footer line to be added is : ***PR1-STAGE_2_CONFIRM***
~ Hoping that I managed to explain the requirement here. Could some one kindly help?
In terms of the logical flow, I was thinking I have to have 2 loops. Outer one to fetch each file and inner one to compare if (file.Contains(Zone[j]) && file.Contains(Stage[j])) then EoL = FooterLine[j] else EoL= "" break..
Zone Stage FooterLine
PR1 STAGE_1_DETECT ***PR1-STAGE_1_DETECT***
PR1 STAGE_2_CONFIRM ***PR1-STAGE_2_CONFIRM***
SE1 STAGE_1_FORMULA ***SE1-STAGE_1_FORMULA***
SE1 STAGE_2_BUILD ***SE1-STAGE_2_BUILD***
SE2 STAGE_3_TEST ***SE2-STAGE_3_TEST***
AD1 STAGE_1_DEMO ***AD1-STAGE_1_DEMO***
AD1 STAGE_2_PUBLISH ***AD1-STAGE_2_PUBLISH***
AD2 STAGE_2_PUBLISH ***AD2-STAGE_2_PUBLISH***
Continue reading...