Skip to content

ComparisonDefinition

Jonathan Scott edited this page Sep 22, 2020 · 4 revisions

This is an example configuration file for defining the comparison behaviour

<?xml version="1.0" encoding="utf-8"?>
<ComparisonDefinition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <Delimiter>,</Delimiter>
  <KeyColumns>
    <Column>ABC</Column>
    <Column>DEF</Column>
  </KeyColumns>
  <ExcludedColumns>
    <Column>COL D</Column>
    <Column>COL E</Column>
  </ExcludedColumns>
  <IgnoreInvalidRows>true</IgnoreInvalidRows>
  <HeaderRowIndex>0</HeaderRowIndex>
  <ToleranceValue>0.1</ToleranceValue>
  <ToleranceType>Relative</ToleranceType>
</ComparisonDefinition>

Delimiter

The character used to delimit the csv file, for example ',', '|'

KeyColumns

In the table below, the rows are uniquely constrained by column A and column B

A,B,C,D
1,a,x,x
1,b,x,x
1,b,x,x

ExcludedColumns

Sometimes a column will contain data that will always change from one file to another. A timestamp maybe or unique identifier. ExcludedColumns optionally allows such columns to be ignored from the comparison.

IgnoreInvalidRows

If this is set to true then any rows that have a different number of columns will be excluded from the breaks report This is often the case if a footer row is included

A,B,C,D
1,a,x,x
1,b,x,x
1,b,x,x
This is a footer
It can be multiple rows

HeaderRowIndex

Some CSV files (not strictly speaking CSV standard) can have additional information in the rows above the column headers.

This is a CSV
With extra rows
A,B,C,D
1,a,x,x
1,b,x,x
1,b,x,x

In this case, set the HeaderRowIndex to 2. 0 the default is for the header on the first row of the file

ToleranceType

[Optional] Default = Exact This defines the behaviour of comparison of numeric column values. The tolerance is applied to all numeric values in the file.

ToleranceType can be set to the following values:

ToleranceType = Exact

Break if there is any difference between values

ToleranceType = Absolute

Break if

Math.Abs( referenceDouble - targetDouble )  > ToleranceValue

ToleranceType = Relative

Break if

Math.Abs( (referenceDouble - targetDouble) / referenceDouble )  > ToleranceValue

ToleranceValue

The value used for Absolute or Relative double comparisons This is ignored for Exact ToleranceType