I want to automate a process that I do manually right now. I currently compare two .txt documents (we will call them "D1" and "D2") and create a third (call it "D3") that is a combination of the other two. What I need to do is find a certain string in "D1" and find a similar/same string in "D2". Once there is a match, I need to replace the string in "D1" with the following string that matched "D2" and put it in "D3" as a master file. This sounds a bit confusing so here is what I would like it to look like:
The .txt file format for "D1" is as follows:
1 0010 12345 DEF, DEF-0320
1 0020 ABC-00010G ABC-A,1xx,10%,x1x,0603
1 0020A ABC-00010G ABC-A,1xx,10%,x1x,0603
1 0030A ABC-00127G ABC,4.7xx,10%,x1x,0805
The .txt file format for "D2" is as follows:
10 BARE PCB
20 T C40, C3112
B C5, C45, C48
30 B C25
I want to compare both "D1" and "D2" and find the values '0010', '0020', '0020A', '0030A' from "D1" and the values '10', '20', '30' from "D2". If (when) there is a match between the two sets of numbers (ie, '0010' and '10') I would like to format a new document, "D3", as follows:
1 AAAA BCD 142717 DEF, DEF-0320 T
1 C40 ABC-00010G ABC-A,1xx,10%,x1x,0603 T
1 C3112 ABC-00010G ABC-A,1xx,10%,x1x,0603 T
1 C5 ABC-00010G ABC-A,1xx,20%,x1x,0603 B
1 C45 ABC-00010G ABC-A,1xx,20%,x1x,0603 B
1 C48 ABC-00010G ABC-A,1xx,20%,x1x,0603 B
1 C25 ABC-00127G ABC,4.7xx,100%,x1x,0805 B
The 'T/B' is assigned based on whether or not there is an 'A' following the second number in "D1". 'T' is assigned if there is just a number, 'B' is assigned if there is an 'A'. Also, there are more lines in the "D3" .txt document because of the ',' seperating the different values (ie, for '20', there is 'C40' and 'C3112'). For every ',' in "D2" there needs to be a new line in "D3" that has the same following format as the line above it.