

    ===========================================================================
    ===========================================================================
    ============================                   ============================
    ============================                   ============================
    ============================      C C D F      ============================
    ============================                   ============================
    ============================                   ============================
    ===========================================================================
    ===========================================================================





                CCDF - A Utility to Columnify Comma Delimited Files



                          CCDF is Copyright (C) 1992, 2001


                                         by


     Pinnacle Software, 80 Mornelle Court #310, Toronto, ON, Canada M1E 4P8


        Phone 416-287-8892 -- Web site http://members.aol.com/psoftinfo



    ===========================================================================
                                USER MANUAL OVERVIEW
    ===========================================================================


                    This manual contains the following sections:


    WHY CCDF WAS WRITTEN ----- An introduction to CCDF
    COMMAND FORMAT ----------- How to use the CCDF command
    RETURN CODES ------------- DOS return codes for use in batch files
    SKIPPING FIELDS ---------- How to eliminate unwanted fields
    SMART MODE --------------- Let CCDF figure out the column widths
    GOING THE OTHER WAY ------ How to go from columnar to comma-delimited
    WATCH CCDF IN ACTION ----- Where to find examples of CCDF applications



    ===========================================================================
                                WHY CCDF WAS WRITTEN
    ===========================================================================


    A few months ago, I was astonished to discover that a well-known program
    was incapable of reading the familiar "comma-delimited" format. That is to
    say, it couldn't read an ordinary text file with the data fields broken up
    like this:


    +-------------------------------------------------------------------------+
    |                                                                         |
    |                   "CARRIER","ZIP",23809,"01-10-94"                      |
    |                   "DASI","ZIP",21083,"01-10-94"                         |
    |                   "FORAGE","ZIP",36867,"01-10-94"                       |
    |                   "FREE","ZIP",109669,"01-10-94"                        |
    |                                                                         |
    |                                                                         |
    | Fig. 1 -- Sample of comma-delimited data                                |
    +-------------------------------------------------------------------------+


    In a comma-delimited file, character fields are enclosed in double quota-
    tion marks, while numeric data is presented as-is.  Each field is delimited
    (i.e. separated) by a comma.  The sample above (Fig. 1) represents the
    following four fields:


    +-------------------------------------------------------------------------+
    |                                                                         |
    |                    CARRIER  ZIP   23809  01-10-94                       |
    |                    DASI     ZIP   21083  01-10-94                       |
    |                    FORAGE   ZIP   36867  01-10-94                       |
    |                    FREE     ZIP  109669  01-10-94                       |
    |                                                                         |
    | Fig. 2 -- Sample of columnar data                                       |
    +-------------------------------------------------------------------------+


    ... which just happens to be one of my directories.  The content of the
    data is not the point, here; it's the FORMAT that concerns us.


    Many people exchange data in comma-delimited format, but some programs
    don't read it.  Fortunately, some programs that will not read comma-
    delimited data WILL read columnar data (i.e. data arranged in columns, as
    in Fig. 2).  That's where CCDF comes in...



    ===========================================================================
                                   COMMAND FORMAT
    ===========================================================================


    CCDF ("Columnify Comma-Delimited Files") will read a comma-delimited text
    file and output the fields in columns.  The basic format of the command is
    as follows:

                            CCDF input-file output-file

    For example, to process the comma-delimited file MYFILE.TXT and send the
    result to a text file named OUTPUT.TXT, you would enter this command at the
    DOS prompt (or in a batch file):

                             CCDF MYFILE.TXT OUTPUT.TXT

    This simple command will do the following:

    -- Read each line from MYFILE.TXT
    -- Remove commas
    -- Remove leading and trailing double-quotes from each field
    -- Format the data into columns 20 characters wide
    -- Write each new line to the text file OUTPUT.TXT

    You can select a different column width by specifying a third parameter on
    the command line, as in this example:

                      CCDF C:\ZAPHOD\MARVIN.TXT ARTHUR.TXT 30

    This would read the comma-delimited file MARVIN.TXT (in the ZAPHOD
    directory of drive C:) and output the result into 30-character wide columns
    in the file ARTHUR.TXT.

    If an input field is longer than the specified column width, it is
    truncated (i.e. chopped off) to fit.

    If you want several different widths, you can specify them in a list, as in
    this example:

                     CCDF MYFILE.TXT OUTPUT.TXT 10 20 10 30 10

    This would make the first column ten characters wide, the second column 20
    characters wide, and so on.  If, in the example above, MYFILE.TXT contained
    more than 5 fields, the last parameter (i.e. 10) would be used for the
    remaining fields.

    Any time you need a quick summary of the command formats, start up CCDF
    like this:  CCDF /?



    ===========================================================================
                                    RETURN CODES
    ===========================================================================


    If you are using CCDF in a batch (.BAT) file, you can check it for
    successful operation by using the IF ERRORLEVEL function.  CCDF returns an
    errorlevel of 0 (zero) if it worked, or 255 if it didn't.  CCDF will return
    an errorlevel of 100 if the input file is empty.


    IMPORTANT:  Remember that the IF ERRORLEVEL statement checks the indicated
                level AND HIGHER, so don't use IF ERRORLEVEL 0, because it will
                always be true.  Check the highest errorlevel first.  See your
                DOS manual for details.


    Here is an example of how to use CCDF in a batch file, along with some
    explanatory comments:


    +-------------------------------------------------------------------------+
    |                                                                         |
    |   @ECHO OFF                      <-- Turn off batch file echoing        |
    |   CCDF INPUT.TXT OUTPUT.TXT 50   <-- Run the CCDF command               |
    |   IF ERRORLEVEL 255 GOTO OOPS    <-- Jump ahead if there was an error   |
    |   IF ERRORLEVEL 100 GOTO EMPTY   <-- Jump ahead if the file was empty   |
    |   SEE OUTPUT.TXT                 <-- Use SEE to view output (Note 1)    |
    |   GOTO QUIT                      <-- Jump ahead to the end              |
    |   :EMPTY                         <-- A batch file label                 |
    |   ECHO The input file is empty!  <-- Display a warning                  |
    |   GOTO QUIT                      <-- Jump ahead to the end              |
    |   :OOPS                          <-- A batch file label                 |
    |   ECHO Something didn't work!    <-- Report the error                   |
    |   :QUIT                          <-- A batch file label                 |
    |   ECHO Finished!                 <-- Report the end of the file         |
    |                                                                         |
    | Fig. 3 -- Sample batch file using CCDF                                  |
    +-------------------------------------------------------------------------+


    NOTE 1:  The SEE file viewer/printer (SEE.EXE) is included in the standard
             CCDF package.  It is a freeware product, so you can use it free of
             charge even if you decide you don't need CCDF.



    ===========================================================================
                                  SKIPPING FIELDS
    ===========================================================================


    If you have a comma-delimited file that contains fields you don't want, you
    can eliminate them by setting the corresponding field-length to zero.
    Take, for example, the following file:


    +-------------------------------------------------------------------------+
    |                                                                         |
    |                   "CARRIER","ZIP",23809,"01-01-94"                      |
    |                   "DASI","ZIP",21083,"02-02-94"                         |
    |                   "FORAGE","ZIP",36867,"03-03-94"                       |
    |                   "FREE","ZIP",109669,"04-04-94"                        |
    |                                                                         |
    |                                                                         |
    | Fig. 4 -- Sample of comma-delimited data                                |
    +-------------------------------------------------------------------------+


    Let's say you only want the first, second and fourth fields.  You could
    process the file with this command:

                     CCDF INPUT.TXT OUTPUT.TXT 10 5 0 8

    The resulting output would look like this:


    +-------------------------------------------------------------------------+
    |                                                                         |
    |                         CARRIER   ZIP  01-01-94                         |
    |                         DASI      ZIP  02-02-94                         |
    |                         FORAGE    ZIP  03-03-94                         |
    |                         FREE      ZIP  04-04-94                         |
    |                         :                                               |
    |                         Column 1                                        |
    |                                                                         |
    | Fig. 5 -- Sample of output with column three deleted                    |
    +-------------------------------------------------------------------------+



    ===========================================================================
                                     SMART MODE
    ===========================================================================


    Sometimes, when you're faced with a comma-delimited file, you don't feel
    like figuring out how long each column should be.  CCDF can figure it out
    for you by pre-reading the file.  This is called "Smart Mode".

    To use Smart Mode, replace the column-width list with the /S switch.  For
    example, instead of this:

                  CCDF INPUT.TXT OUTPUT.TXT 10 5 15 30 24 33 11 16

    you can put this:

                            CCDF INPUT.TXT OUTPUT.TXT /S

    This will pre-read the file INPUT.TXT, figure out how wide each column
    should be, and process the file using the calculated column widths.

    The main drawback to Smart Mode is that it takes twice as long to process a
    file, since it has to check the entire file.  You can, however, get CCDF to
    tell you what column widths it used; you can write these down and use them
    in subsequent runs.  To enable the reporting function, use /R instead of
    the /S switch.  For example:

                            CCDF INPUT.TXT OUTPUT.TXT /R

    This runs CCDF in Smart Mode, but afterwards tells you what column widths
    were used.  Note that each column (except the last one) will be one
    character longer than the longest value in that column.  This ensures that
    there is always at least one space between data in each column.  The final
    column is the precise length of the longest value in that column, because
    there is no need to put a space after it.



    ===========================================================================
                                GOING THE OTHER WAY
    ===========================================================================


    CCDF can convert comma-delimited data to columnar, but what if you have a
    columnar report (dumped to a text file) that you want converted to comma-
    delimited format?  Fret not.  There's a convenient program named
    Parse-O-Matic (also by Pinnacle Software), which you can download from our
    web site at http://www.parse-o-matic.com.

    A lot of people have saved a LOT of money by using Parse-O-Matic, because
    it lets them transfer data from one program to another without retyping.
    But that's not all.  Here's a brief list of some of the helpful things
    Parse-O-Matic can do for you:

    Importing, Exporting, Automated Editing, Text Extraction, Data Conversion,
    Table Lookup, Retabulation, Info Weeding, Selective Copying, Binary-File to
    Text, Report Reformatting, Wide-Text Folding, Auto-Batch Creation, Tab
    Replacement, Character Filtering, Column Switching, DBF Interpretation.



    ===========================================================================
                                WATCH CCDF IN ACTION
    ===========================================================================


    The CCDF package contains a batch file, named INFO.BAT, which provides you
    with some demonstrations of CCDF.  To run the demo, enter INFO at the DOS
    prompt (or click on it, in Windows).  The demo also explains how you can
    purchase a fully registered copy of CCDF.



