Here is some sample input.
File1
-----
X Y Category1 Category2 Value1 Value2 Value3 Result
2 -9 1.0 2.0 1.1e3 1.234 -0.003 PASS
File2
-----
X Y Category2 Category1 Value3 Value1 Value2
2 -9 1 1 -0.003 1.1e3 1.2345 FAIL
The main points to note are:
1. The columns are not necessarily in the same order (the main reason I started this in the first place).
2. Data is a mixture of strings and numbers of differing precisions (but all base10).
To take account of the differences in column order, I rebuild the data using a hash keyed by the XY coordinate (first 2 columns) and using the actual column name e.g
...other code omitted...
$data1{"$x,$y}{$colnames[$colnum]} = $linedata[$colnum];
Output would be something like:
X=2 Y=9 Category2
X=2 Y=9 Value2
X=2 Y=9 Result
i.e. a list of the column names for which the data did not match between the two files, allowing for strings an numerical values, and accuracy to a certain precision (using the $eps approach detailed elsewhere in this thread)
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.