Page 1 of 1

Displaying Columns

PostPosted: Fri Nov 12, 2021 8:52 pm
by Mark Harvard
I have a table in a sequential dataset and I need to read the columns down. Is it possible to use EXECIO and iterate through each column and store them in a nested array?

Re: Displaying Columns

PostPosted: Fri Nov 12, 2021 9:01 pm
by prino
Maybe you can show what you actually want to do with some example data, a picture paints a thousand words.

And REXX doesn't have arrays, let alone nested arrays.

Re: Displaying Columns

PostPosted: Fri Nov 12, 2021 9:07 pm
by Mark Harvard
I have a table,

    header_title_1 header_title_2
    data


Re: Displaying Columns

PostPosted: Fri Nov 12, 2021 9:17 pm
by Mark Harvard
I have a table,

    header_title_1 header_title_2
    data. data
    data data
    data data


I want to grab header_title_1, and all data in that column, store it, then move to the next column and do the same thing for n amount of data.
I am still new to Rexx but I know how to do it in python and try to associate the terminology. I know they don't have arrays, but called compound variables

Re: Displaying Columns

PostPosted: Fri Nov 12, 2021 10:51 pm
by sergeyken
0) Learn how to use the CODE tags in your postings

1) how do you distinguish data between different columns?
- each column data begins in a specific fixed position?
- column data are separated by a specific character/string?
- something else?

2) where do you plan to "store" the data extracted from each column?
- in an array?
- in a separate dataset?
- somewhere else?

3) the "saving" one column at a time doesn't make sense: you would need to re-read the input dataset again, and again - for each one of your columns.
It would be much better saving data for ALL columns in parallel, from each single record

Re: Displaying Columns

PostPosted: Fri Nov 12, 2021 11:11 pm
by sergeyken
. . . . . . . . . . .
"EXECIO * DISKR INPUTDD (FINIS"
Do L = 1 by 1 While Queued() > 0
   Parse Pull Col1.L Col2.L Col3.L ... ColN.L
   /* or, for comma-separated columns       */
   /* Parse Pull Col1.L ',' Col2.L ',' Col3.L ',' ... ',' ColN.L ',' */   
   /* or, for columns with fixed size (let's say 10 bytes each)      */
   /* Parse Pull Col1.L +10 Col2.L +10 Col3.L +10 ... +10 ColN.L +10 */
   /* or, for columns with fixed positions      */
   /* Parse Pull Col1.L =10 Col2.L =20 Col3.L =30 ... =90 ColN.L =100 */
End L
L = L - 1
/* at this point:                                                                         */
/*      L                   = the number of elements,                                     */
/*      Col1.1 ... ColN.1   - headers of each column 1 to N                               */
/*      Col1.X ... ColN.X   - data values for columns 1 to N, from lines 2 to max lines read */
. . . . . . . . . . . .
 

Re: Displaying Columns

PostPosted: Sun Nov 14, 2021 11:28 am
by Pedro
I know they don't have arrays, but called compound variables


I suggest you read about stem variables in the rexx manuals. Sergeyken has provided a good example of how to use one.

How the data is delimited is important. It might be tricky if some of columns have text with imbedded blanks.

Also learn about the PARSE statement.