Transformenator CSV Transform

The ExtractCSV utility function takes a file and divides it up into fixed-length records with fixed-length fields that you specify and creates a comma-separated values (CSV) file of them. Data from the original file can be interpreted as ASCII text, as EBCDIC text, or as hexadecimal values.

The table below defines the keywords and values used to define an interpretation of a file as records. The case of the keywords is not significant. All numerical values are given in hexadecimal.
Keyword Explanation Example
; Comment, will be ignored ; This text will not be considered
FirstRec (Optional) Offset (in hex bytes) to the first record to be considered FIRSTREC=0E00
NextRec Offset (in hex bytes) to the next record NEXTREC=100 ; One record every 0x100 bytes
SelectIf (Optional) criteria that must be met to consider a record for output; specification first lists the offset within the record, followed by a comma, followed by one or more hex bytes that must match. Multiple SelectIf clauses may be used to produce logical OR conditions. SELECTIF=00,40 ; First byte must be 0x40 to be valid SELECTIF=01,20 ; Or, second byte can be 0x20

The table below defines export instructions for a single field. Each field definition must contain one each of the following four keywords. Multiple sets of these specifications typically make up a full record to export. The case of the keywords is not significant. All numerical values are given in hexadecimal.
Keyword Explanation Example
Name Field name to be exported on header row of output CSV file NAME="Field 1"
Origin Offset within the record to this field's data ORIGIN=01
Length Length of this field's data LENGTH=0a
Interp or InterpLiteral Interpretation of field data to export - one of:
ASCII - ASCII text
EBCDIC - EBCDIC text
HEX - Hexadecimal notation
Text will be encoded in the output CSV file as specified with surrounding quotes. With InterpLiteral, additional syntax and quoting will be added to the output CSV file that convinces spreadsheets not to re-interpret numerical values.
INTERPLITERAL=EBCDIC

Example

Below is an example csv-transform file that interprets a disk image taken from an IBM System/36 floppy disk that was used for record storage: ; ; Custom IBM System/36 to CSV transform ; FIRSTREC=0E00 ; First record starts at 0xE00 NEXTREC=100 ; Records continue every 0x100 bytes SELECTIF=00,40 ; The zeroeth byte needs to be an EBCDIC space ; NAME="Field 1" ; First field definition ORIGIN=01 ; Starts at byte 0x01 (zero-indexed) LENGTH=09 ; Runs for a length of 0x09 bytes INTERP=EBCDIC ; Interpret data as EBCDIC ; NAME="Field 2" ; Second field definition ORIGIN=0A ; Starts at byte 0x0a (zero-indexed) LENGTH=1E ; Runs for a length of 0x1e bytes INTERP=EBCDIC ; Interpret data as EBCDIC ; NAME="Field 3" ; Third field definition ORIGIN=28 ; Starts at byte 0x28 (zero-indexed) LENGTH=05 ; Runs for a length of 0x05 bytes INTERP=EBCDIC ; Interpret data as EBCDIC ; NAME="Field 4" ; Fourth field definition ORIGIN=2d ; Starts at byte 0x2d (zero-indexed) LENGTH=02 ; Runs for a length of 0x02 bytes INTERP=EBCDIC ; Interpret data as EBCDIC ; NAME="Field 5" ; Fifth field definition ORIGIN=2f ; Starts at byte 0x2f (zero-indexed) LENGTH=3d ; Runs for a length of 0x3d bytes INTERP=HEX ; Interpret data as hexadecimal bytes