I have one tsv file which which is exported from some cable testing software. I have to distinguish between the data that was already in the file and newly added data during that week, which i have done. I now have 2 tsv files, one that has old data in and one that has the newly added data.
I need to compare each line in the newfile to each in the oldfile and remove duplicates. It is the 2, 3 & 6 elements in each line that need to be compared as the others contain unique data.
e.g.
0 <t> 1 <t> 2 <t> 3 <t> 4 <t> 5 <t> 6
"12345" <t> "cdf34" <t> "l1" <t> "r1" <t> "notes" <t> "" <t> "l1:r1 l2:r2"
Once a dupe has been found the part no. (0) needs to be added to the notes field(4) its dupe of in the oldfile.
if a dupe isnt found an 'A' needs to be added to the front of the part no (to make the line approved) and then that line is to be added to the bottom of the oldfile.
I have attempted this by extracting the data from the files into an array and spliting each line at the \t to make each line an array. Ive then used a for loop inside another accessing one line from the newfile and comparing its elements to the elements in every line in the oldfile, the problem is i cant seem edit the information in the files and the lines are printed several times as it loops through.
I hope someone can help me with this, im struggling a bit as ive only been learning perl for the last 2 wks.
thanks, steve.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.