FW:Using comma delimited files

Libero.B.Dalle-Vacche@telia.se Libero.B.Dalle-Vacche@telia.se
Tue, 9 Mar 1999 20:54:17 +0100


Hello,

Here is my contribution to the problem of comma delimited files.

With this QTP you can extract as many fields you want delimited by any
character.

run

set proc nolim

global  temp sp char*1 parm prompt "Separator " ; ex "," or ";"
global  temp counter zoned*4 parm prompt "Counter " ; no of items to    
                                               ; extract

request

acce any_file ; who as at least as many record as counter

temp t_c
item t_c count

subfile loop  if t_c <= counter &
      include counter index counter segment counter

request

access ascii256

def d_rec char*257 = trunc(rec256) + sp
temp rec_no
item rec_no count

subfile sub_rec include rec_no , d_rec, counter

request

access *sub_rec link counter to counter of *loop

sorted on rec_no

temp item_no
item item_no count reset at rec_no

temp t_pos
item t_pos reset at rec_no to 1

temp t_str char*256
item t_str = d_rec [t_pos:(257 - t_pos)]

def d_ind = index (t_str , sp)
def d_item char*50 = t_str [1:(d_ind - 1)]

subfile sub_item keep if d_ind <> 0 & ;the subfile will include the     
                                    ;extracted fields one field
   include rec_no  , &                ;for each record
           item_no , &
           d_item

item t_pos = t_pos + d_ind

go


Libero Dalle Vacche
Stockholm 
Sweden

= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
Subscribe: "subscribe powerh-l" in message body to majordomo@lists.swau.edu
Unsubscribe: "unsubscribe powerh-l" in message to majordomo@lists.swau.edu
powerh-l@lists.swau.edu is gatewayed one-way to bit.listserv.powerh-l
This list is closed, thus to post to the list, you must be a subscriber.