Converting Delimited Files (Pickering, John (NORBORD))
Pickering, John (NORBORD)
PICKERIJ@norbord.com
Tue, 13 Nov 2001 14:10:15 -0500
Hold on a minute Karen!
I think you missed what I'm doing in the Qtp sample below. Nowhere do I
increment t_pos by the length of anything!
I store the input buffer in a work field.
Then I store the work field from position 1 up to just before the first tab
in some temporary item.
Then I store the work field from just after the first tab to the end in the
work field.
And I repeat the last 2 statements as many times as there are fields.
Just clarifying things for the archives :-)
JWP
> -----Original Message-----
> From: Karen Barrett [SMTP:kbarrett@denkor.com]
> Sent: Tuesday, November 13, 2001 1:55 PM
> To: PowerhouseList
> Subject: RE:Converting Delimited Files (Pickering, John (NORBORD))
>
> 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
>
>
>
>
> = = = = = = = = = = = = = = = = = = = = = = = = = = = =
> Mailing list: powerh-l@lists.swau.edu
> Subscribe: "subscribe" in message body to powerh-l-request@lists.swau.edu
> Unsubscribe: "unsubscribe" in message body to
> powerh-l-request@lists.swau.edu
> http://lists.swau.edu/mailman/listinfo/powerh-l
> This list is closed, thus to post to the list you must be a subscriber.