Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
Iam struggeling to use a for each .. next statement in order to load every 50th record into a tabel.
I have a file containing thousends of lines and i need a script to load the 1 line then the 51 line then 101 line ..etc ( everytime 50 rows further).
any suggestions how this for each .. next would look like?
thanks for any help!
Linda Monincx
Hi Linda,
Try this instead of a loop:
LOAD ...
FROM ...
WHERE mod(RECNO() / 50) = 1;
This takes the record number of that in the input table, divides by 50 and compares the remainder to 1.
Hope this helps.
Regards,
Gordon
whoops! That should read:
WHERE mod(RECNO(), 50) = 1;
Thanks that works when i start with my first row, but what if i want to extract the 43 row and then row 93?
Linda
Hi Linda,
A variant ... WHERE mod(RECNO() + 49, 50) = 1;
Luis
Linda,
these are all variations of the same idea - use RecNo() within the WHERE clause to form your conditions:
where exists(MyFavoriteNumbers, Recno())
or
where match(RecNo(), 37, 43, 467) > 0
etc...
Using for each ... loop in your case would be extremely slow... Gordon's idea will work much better.