Class CSVComparer

Object
CSVComparer

public class CSVComparer extends Object
Compares two CSV files to determine if they are identical or not.
  • Constructor Details

    • CSVComparer

      public CSVComparer(String regExSeperator, boolean firstLineHeaders, int ignoreFirstNumberColumns, boolean sortLines, boolean rejectZeroRows)
      Creates a new CSVComparer instance.
      Parameters:
      regExSeperator - The separator for the CSV file (a regular expression for split function)
      firstLineHeaders - Whether the first line of the CSV file headers
      ignoreFirstNumberColumns - Ignore the first number of columns (left most) when measuring equality
      sortLines - If true, all lines in the CSV file are sorted before comparison. If false, the order remains unchanged.
      rejectZeroRows - An exception is thrown if the CSV file has zero rows
  • Method Details

    • areCSVFilesEqual

      public boolean areCSVFilesEqual(Path path1, Path path2, PrintStream messageStream) throws CSVReaderException
      Are two CSV files equal?
      Parameters:
      path1 - path to first file to compare, without any lines having been already read
      path2 - path to second file to compare, without any lines having been already read
      messageStream - if CSV files aren't equal, additional explanation messages are printed here
      Returns:
      true iff the two files are considered equal.
      Throws:
      CSVReaderException - if something goes wrong.