Using Comma delimited files with powerhouse
Neil Harvey
neil@nha.co.za
Thu, 4 Mar 1999 07:36:47 +0200
In my experience, I have hardly ever found anything that I cannot do
with PowerHouse.
Here is a snippet of code that will read a comma (or any other
separator) delimited file, and return the results into a set of fields
in a subfile.
Obviously, you will need to modify the size of the fields, and their
number, to suit, but this should start you off.
Also, it is an HP3000 MPE PowerHouse qtp source, so you may have to
think about the input file.
Notes:-
wfile is defined in the dictionary as a 256 byte general purpose file,
but it could be a subfile. The :file statement just before the access
statement tells the operating system to open "commaf1".
sp is the separator
add fields as required, and watch the length.
commaf1 looks like:-
f1,f2,f3,f4,f5,f6,f7,f8,f9,f10
a,b,c,d,e,f,g,h,i,j
100,233,455,ABC,tredf,833433,010199,2000/03/01
commaf2 is a subfile with ten fields (f01, f02, f03 etc)
Regards
Neil Harvey
request undelim on calc errors report
:file wfile=commaf1
access wfile
temp P00 int
temp P01 int
temp P02 int
temp P03 int
temp P04 int
temp P05 int
temp P06 int
temp P07 int
temp P08 int
temp P09 int
temp P10 int
def sp char*1 = ","
temp y-rec char*1024
item y-rec = trunc(w-rec) + sp
item P00 = 0
item P01 = P00 + index(y-rec[P00 + 1:1024],sp)
item P02 = P01 + index(y-rec[P01 + 1:1024],sp)
item P03 = P02 + index(y-rec[P02 + 1:1024],sp)
item P04 = P03 + index(y-rec[P03 + 1:1024],sp)
item P05 = P04 + index(y-rec[P04 + 1:1024],sp)
item P06 = P05 + index(y-rec[P05 + 1:1024],sp)
item P07 = P06 + index(y-rec[P06 + 1:1024],sp)
item P08 = P07 + index(y-rec[P07 + 1:1024],sp)
item P09 = P08 + index(y-rec[P08 + 1:1024],sp)
item P10 = P09 + index(y-rec[P09 + 1:1024],sp)
temp LL int
item LL = size(trunc(y-rec))
def F01 char*50 = Y-REC[(P00 + 1):(P01 - P00 - 1)] if P00 = 0
def F02 char*50 = Y-REC[(P01 + 1):(P02 - P01 - 1)] if P01 <> LL
def F03 char*50 = Y-REC[(P02 + 1):(P03 - P02 - 1)] if P02 <> LL
def F04 char*50 = Y-REC[(P03 + 1):(P04 - P03 - 1)] if P03 <> LL
def F05 char*50 = Y-REC[(P04 + 1):(P05 - P04 - 1)] if P04 <> LL
def F06 char*50 = Y-REC[(P05 + 1):(P06 - P05 - 1)] if P05 <> LL
def F07 char*50 = Y-REC[(P06 + 1):(P07 - P06 - 1)] if P06 <> LL
def F08 char*50 = Y-REC[(P07 + 1):(P08 - P07 - 1)] if P07 <> LL
def F09 char*50 = Y-REC[(P08 + 1):(P09 - P08 - 1)] if P08 <> LL
def F10 char*50 = Y-REC[(P09 + 1):(P10 - P09 - 1)] if P09 <> LL
:purge COMMAF2
subfile COMMAF2 keep include &
f01, &
f02, &
f03, &
f04, &
f05, &
f06, &
f07, &
f08, &
f09, &
f10
set pro lim 1000000
set lock update
go
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
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.