Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

Re^3: Equality checking for strings AND numbers

by rpanman (Scribe)
on Jul 13, 2007 at 06:32 UTC ( #626386=note: print w/replies, xml ) Need Help??

in reply to Re^2: Equality checking for strings AND numbers
in thread Equality checking for strings AND numbers

Looking at the Text::Diff module, I noticed the following:
my $diff = diff \&reader1,\&reader2;
I assume that this means you can use a subroutine to return the column you need from the input files and then just use Text::Diff to compare.

Do you have some sample input files? What sort of output are you expecting to be generated (a list of the differences, print to screen etc) and what should the format of this output be??
Updated: Questions added

Replies are listed 'Best First'.
Re^4: Equality checking for strings AND numbers
by Anonymous Monk on Jul 13, 2007 at 14:26 UTC
    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)

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://626386]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (12)
As of 2018-07-20 14:22 GMT
Find Nodes?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?

    Results (434 votes). Check out past polls.