Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I have loaded a table from a data source.
Now I want to perform some transformations whereby I need to know the value of the next record to add new fields. I know PEEK lets me go back, but is there anything that I can see 1 record ahead?
You can look ahead using peek(). peek() row is 0 based and recno() is 1 based, so it's easy to look ahead one record like this:
data:
LOAD * INLINE [
X
A
B
C
]
;
data2:
LOAD
X,
peek('X', recno(), 'data') as Y
RESIDENT data
;
-Rob
Order it the other way around and use Peek 🙂
that's what i am trying but thought there must be a better way. i want to avoid multiple loads of the same table to be able to do one thing.
You can look ahead using peek(). peek() row is 0 based and recno() is 1 based, so it's easy to look ahead one record like this:
data:
LOAD * INLINE [
X
A
B
C
]
;
data2:
LOAD
X,
peek('X', recno(), 'data') as Y
RESIDENT data
;
-Rob
that is it. i was playing around with it but didn't know how to use it. problem SOLVED! thanks.
I am trying the above code,
but it is really not working in my case
This is the excel table I created
Z | C |
3 | a |
5 | b |
4 | c |
8 | d |
7 | e |
This the script
data:
LOAD Z,
C,
peek('Z',recno(),'data') as PEEK
In column PEEK I end up with all fields marked with '-'
thank you!