Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Thu, 07 Jul 2005 @ 17:48:25 GMT


     
  <Prev Next>   <<First <Prev Next> Last>>  


Subj:   Re: Internal Format of MLOAD/FEXP data files
 
From:   Geoffrey Rommel

  Does anyone know a way to take an "internal format" data file and output it somehow back out to VARTEXT mode, perhaps using one of the utilities?  


You seem to be referring to the HostData or similar columns in the error tables created by MultiLoad and FastLoad. These columns contain the record in raw bytes as they came from the source system. Therefore, all you have to do is copy+paste the hex digits into a text file and then run them through a script that converts the hex digits back to ASCII or EBCDIC data. The Perl script below does this for ASCII only; EBCDIC is left as an exercise for the reader.

     #!/usr/bin/perl
     # Take a file of printable hex digits, such as those shown in a
     # Teradata load error table, and print them in character with
     # hex vertical.
     # Options:
     #     -wN  Width at which to break the lines; default=78.
     #     -a   Show plain ASCII characters (up to '~') only. Default is
     #          to show all characters up to x'FF' except controls.
     use Getopt::Std;
     getopts("w:a");
     $WIDTH = $opt_w || 78;
     $ASCII_ONLY = $opt_a;
     # Printable ASCII characters
     if ($ASCII_ONLY) {
        $ASCIIP = (' 'x32) .
          ' !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNO' .
          'PQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~ ' . (' 'x128);
     } else {
        $ASCIIP = (' 'x32);
        for ($c = 32; $c < 127; $c++) { $ASCIIP .= chr($c); }
        $ASCIIP .= ' 'x34;
        for ($c = 161; $c < 256; $c++) { $ASCIIP .= chr($c); }
     }
     # "Zone" and "numeric" portions
     $ZONES = '0'x16 . '1'x16 . '2'x16 . '3'x16 . '4'x16 . '5'x16 .
      '6'x16 . '7'x16 . '8'x16 . '9'x16 . 'A'x16 .
      'B'x16 . 'C'x16 . 'D'x16 . 'E'x16 . 'F'x16;
     $NUMS = '0123456789ABCDEF'x16;
     # Dashes
     $DASHES = '-'x256;

     while (<>) {
        chomp;
        $chars = pack("H*", $_);
        print_line($chars);
     }

     # Print a line in ASCII and hex with line breaks and such.
     sub print_line {
      my $line = shift;
      print fcs_xlate($line, $ASCIIP), "\n";
      print fcs_xlate($line, $ZONES), "\n";
      print fcs_xlate($line, $NUMS), "\n";
      print fcs_xlate($line, $DASHES), "\n";
     }

     # Full Collating Sequence translation
     sub fcs_xlate {
      my ($in, $table) = @_;
      my ($i, $result);
      $result = '';
      for ($i=0; $i < length($in); $i++) {
         $result .= substr($table, ord(substr($in, $i,1)), 1);
      }
      return $result;
     }

 
 
 
 


     
  <Prev Next>   <<First <Prev Next> Last>>  
 
 
 
 
 
 
 
 
  
  Top Home Privacy Feedback  
 
 
Copyright for the TeradataForum (TDATA-L), Manta BlueSky    
Copyright 2016 - All Rights Reserved    
Last Modified: 15 Jun 2023