Documentation » Command Line Tools » lcsvdiff.pl

CSVDiff

LRpt::CSVDiff - A module for comparing 2 sets of csv files
 LRpt::CSVDiff - A module for comparing 2 sets of csv files


NAME

LRpt::CSVDiff - A module for comparing 2 sets of csv files


SYNOPSIS

  lcsvdiff.pl [OPTIONS]... FILE1 FILE2


DESCRIPTION

This module is a part of LRpt (LReport) library. It is used to compare 2 sets of csv files and report found differences. You should not use LRpt::CSVDiff module directly in your code. Instead you should use lcsvdiff.pl tool, which is a simple wrapper around the module. lcsvdiff.pl looks like this:

  use LRpt::CSVDiff;
  use strict;
  
  diff( @ARGV );


COMMAND LINE OPTIONS

--all
If set, not only differences are reported, but all rows from both rowsets. Currently this is used as in input for lrptxml.pl

--chunk_size=num
Number of rows retrieved in one chunk. If not defined - default chunking size is used (1000). If equal to zero, than no chunking is used (all rows are loaded to memory)

--ext=ext
Files extension of csv files.

--global_keys
Orders lcsvdiff.pl to look for keys' definitions in a file defined by LRPT_GLOBAL_KEYS_FILE variable or keys.txt file.

--help
Prints help screen.

--key=col_idx1[,col_idx2]
Indices of columns which should be used as key. Indices are 1 based. --key=col_idx1,col_idx2 means that all columns from col_idx1 to col_idx2 (inclusive) are part of a key. In order to specify key build of non-consecutive columns, use --key option several times.

--key_cols=col1[,...]
Names of columns which should be used as key. In contrary to --key option, no ranges are assumed. Each columns has to specified explicitly.

--keys_file=file
Name of the file containing row keys definitions. See LRpt for more details on row key files.

--sep=sep
Character used as a field separator. Default is tab or the one defined by LRPT_CSV_FIELD_SEPARATOR.

--skip_cols=col1[,...]
Names of columns which should be skipped in comparison.

--skip_cols_file=file
Name of a file containing information, which column should be skipped in comparison for a given select.

FILE1
A file name or a directory containing files with before state.

FILE2
A file name or a directory containing files with after state.


METHODS

In this sections you will find a more or less complete listing of all methods provided by the package.

diff

  diff( @ARGV );

Main function. @ARGV is processed by standard Getopt::Long module. Switches have the following meaning (see SYNOPSIS.

--all
If set, not only differences are reported, but all rows from both rowsets.

--key=string
Row key defined in command line as one string. Don't use it. I will probably get read of this switch in future

--keys_file=file
Name of the file containing row keys definitions

--chunk_size=num
Number of rows retrieved in one chunk. If not defined - default chunking size is used. If equal to zero, than no chunking is used (all rows are loaded to memory

before_dir
A file name or a directory containing files with before state.

after_dir
A file name of a directory containing files with after state.

compare_files

  compare_files( $st1_file, $st2_file );

Compares 2 files. If one or two of given filenames are actually directory names then diff behavior is mimiced.

    find( sub { 
              if( $File::Find::name eq $st1_file ){
                  return;
              }
              if( not ( $File::Find::name =~ /\.$ext$/ ) ){
                  return;
              }
              my $cmp_path = $File::Find::name;
              $cmp_path =~ s/^$st1_file\///;
              $st1_files{ $cmp_path } = 1; 
          }, 
          $st1_file );
    find( sub { 
              if( $File::Find::name eq $st2_file ){
                  return;
              }
              if( not ( $File::Find::name =~ /\.$ext$/ ) ){
                  return;
              }
              my $cmp_path = $File::Find::name;
              $cmp_path =~ s/^$st2_file\///;
              $st2_files{ $cmp_path } = 1; 
          }, 
          $st2_file );

compare_two_files

  compare_two_files( $file1, $file2 );

Performs row/column oriented comparison between 2 files

open_db_connection

  open_db_connection()

Opens a database connection. Loads a connection file and evals it.

print_usage

  print_usage();

Prints usage text.


SEE ALSO

The project is maintained on Source Forge http://lreport.sourceforge.net. You can find there links to some helpful documentation like tutorial.


AUTHORS

Piotr Kaluski <pkaluski@piotrkaluski.com>


COPYRIGHT

Copyright (c) 2004-2006 Piotr Kaluski. Poland. All rights reserved.

You may distribute under the terms of either the GNU General Public License or the Artistic License, as specified in the Perl README file.

 LRpt::CSVDiff - A module for comparing 2 sets of csv files