The simplest way to do this is to read the file directly from the OS
file system as follows

  EQU COMMA TO ','
  EQU QTE TO /"/
  EQU NULLS TO ""

  LOOP
  UNTIL last.byte

       OSBREAD block FROM file.var AT bbyte LENGTH lgth
       bbyte += lgth

        last.byte = INDEX(block, @EOF)
        IF last.byte THEN block = block[1,  (last.byte - 1)]

        CHANGE @CRLF to @FM IN block
        block<1> = left.overs : block<1>
        last.fmc = DCOUNT(block, @FM)

        IF NOT(last.byte) THEN
           left.overs = block<last.fmc>
           last.fmc = last.fmc - 1
       END

        FOR fmc = 1 TO last.fmc

              this.line = block<fmc>
             comma.count = COUNT(this.line, COMMA)
             qt.comma.count = COUNT(this.line, QUOTE(COMMA))

             BEGIN CASE
                   CASE comma.count = 2
                         CHANGE COMMA TO @VM IN this.line
                         CHANGE QTE TO NULLS IN this.line
                   CASE qt.comma.count = 2
                         CHANGE QUOTE(COMMA) TO @VM IN this.line
                   CASE 1
                                  {otherwise break this.line down
using logic driven by INDEX & GROUP functions}
            END CASE

             {processes}

        NEXT FMC

  REPEAT

This requires writing a little extra code to deal with the line and
element parsing, but that should all be boiler plate that is reusable
with appropriate modifications to read lengths and CSV delimiter
counts whenever you have to read a CSV file.

In my experience on WINDOWS, the OSBREAD and OSBWRITE functions are
way faster than READSEQ and WRITESEQ on larger files because only a
byte-specific, limited portion of the file has to be dealt with at a
time

-- 
Please read the posting guidelines at: 
http://groups.google.com/group/jBASE/web/Posting%20Guidelines

IMPORTANT: Type T24: at the start of the subject line for questions specific to 
Globus/T24

To post, send email to [email protected]
To unsubscribe, send email to [email protected]
For more options, visit this group at http://groups.google.com/group/jBASE?hl=en

Reply via email to