Converting Delimited Files (Pickering, John (NORBORD))
Karen Barrett
kbarrett@denkor.com
Tue, 13 Nov 2001 10:54:48 -0800
John's example also contains the principles that lead to a nice clean
solution -
Use temp/item and increment the position variable t_pos = t_pos + length of
prior element
for each possible element in the record input file.
Quiz was not an option as my input file was WAY too wide.
Karen Barrett
Denkor Dental Management Corp.
;--------
From: "Pickering, John (NORBORD)" <PICKERIJ@norbord.com>
To: powerh-l@lists.swau.edu
Subject: RE: Converting Delimited Files
Date: Mon, 12 Nov 2001 12:49:57 -0500
Qtp can be just as fast. But not if you use a series of 27 cascading DEFINE
statements to extract the 27 tab delimited fields. It will be far more
efficient to use a series of TEMPorary items and ITEM statements to do this.
Something like:
global temp t_09 int*2 initial 09
global temp t_tab char*1 initial char(t_09)[2:1] ; adjust for your os
request dismantle
access tab_delim_file
temp t_pos int*3 ; position of tab in work field
temp t_work char*200 ; as big as the record in tab_delim_file
item t_work = lj(record of tab_delim_file)
temp t_field_1 char*10 ; first column, adjust type and size to suit
item t_pos = index(t-work,t_tab)
item t_field_1 = t_work[1:t_pos - 1]
item t_work = lj(t_work[t_pos + 1 :200])
Repeat the last 4 statements for the rest of the 27 fields. The only wrinkle
is handing the last column since not all tab delimited files will put a tab
after the rightmost column. If the last column is numeric then you can use a
space in the INDEX function. If the last column is character and may contain
spaces then about the best you can do is simply take as much of the work
field as will fit in the item.
Regards,
JWP