Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Validating Flat-file Messages

...

The validation of a flat-file message such as a TSV file generated in accordance with the Digital Sales Reporting Message Suite Standard (DSR) can be conducted by a tool developed by Google. The tool is available to download from GitHub at https://github.com/ddexnet/dsrf.

The tool can be deployed on any computer running Max OS X, LinuX or MS Windows with a Python v2.7 (or later) interpreter installed. The tool comes with a manual and can be used with a small Perl script dsrf-conf.plas follows:

Code Block
languagebash
themeMidnight
> dsrf-conf.pl file.tsv

The two screen shots below show a successful and an unsuccessful test. In each case, a log file containing all findings is generated. The script is provided in Annex A.

Image Modified

Image Modified

Perl Script for DSRF Validator 

Expand

This is a Perl script calling the DSRF Validator discussed in Clause 3 to test whether a DSR file is in accordance with the relevant profile. The script, written for OS X, expects the variables $validator to point to the location of the DSRF Validator. 

Code Block
languageperl
themeEmacs
#!/usr/bin/perl
use strict;
use warnings;
 
print "\ndsrf-conf.pl -- tool to check conformance of a DSRF file. \n"
print "(c) 2016 Digital Data Exchange, LLC, utilising Google's dsrf library\n\n";
 
#
# set variables (filelist being the alphabetical list of input files)
#
my $validator = "/Users/nrump/bin/dsrf";
my $parser = $validator . "/run_dsrf.py";
my $conformance = $validator . "/conformance/conformance_processor.py";
my $log = "/tmp/example.log";
my $log2 = "/tmp/example2.log";
my $usage = "Please use the script as follows:\n\tdsrfconf.pl FILE [FILE*]\nProgram aborted";
my @filelist = sort (@ARGV);
my $filecount = $#ARGV + 1;
my $profile = "";
$/ = "\r";     # to support all kinds of CR/LF/CRLF combos
 
#
# see if at least one file has been given and that all files exist
#
die "No file to process. $usage" if ( $filecount < 1);
-f or die "File '$_' does not exist. $usage" foreach (@filelist);
 
#
# open the first file (which is ...1ofx... as the array is sorted) and obtain the profile
#
open (FILE, "<$filelist[0]");
while(<FILE>){
  s/^\s+//; # make sure there are no leading spaces
  next unless (/^HEAD/);
  my @fields = split "\t";
  $profile=$fields[2];
  last;
}
close FILE;
 
#
# end validation if there is no profile
# if there is: remove all spaces from the profile name (as this is what the tool expects)
#
if ( $profile eq "") {
  print "    No profile given in $filelist[0]\n    Conformance cannot be tested\n";
  open FILE, $filelist[0].log; 
  print FILE "No profile given in $filelist[0]\n    Conformance cannot be tested\n";
  close FILE;
  exit;
}
print "Checking input file(s) against the $profile:\n\n";
$profile =~ s/ //g;
 
system "python $parser @filelist | python $conformance > $log2";
system "cat $log $log2 > $filelist[0].log"; 
system "rm -f $log $log2";
print "\n\nAll done. Results are in $filelist[0].log\n";

 


Anchor
fn1
fn1
[1] At least for comparatively recent versions of the DDEX standards. For older versions there may be the possibility that the online AVS XSD has been updated since the offline XSD had been published. 

...