On 4/30/2013 11:21 AM, Sathya wrote:
> Hi all,..
> 
> I have a requirement here. Need guidance in doing that. Any help will be 
> useful. 
> 
> TIA.
> 
> I have a flat file with tab delimited records and the file looks like below:
> 
> abcd 1234
> cdef 3478
> ghae 6284
> ...
> 
> I have to fetch the data 'abcd' and 'cdef' from this flat file and fetch 
> some corresponding attributes from a file which has 'abcd' and 'cdef' as 
> the key values. Please let me know if this could be done. If yes any kinda 
> basic suggestions in doing that will be helpful. 
> 
Lots of ways to solve this problem, here's a very quick and dirty
untested piece of code written off the top of my head...

PROMPT ""
EQUATE TABCHAR TO CHAR(7)
*

OPEN "", "&UFD&" TO F.UFD ELSE STOP "CAN'T OPEN UFD"
READ D.UFD FROM F.UFD, "xxx.tabdelimitedname" ELSE
CRT "Can't read tab-delimited file from current directory"
STOP
END
OPEN "", "OTHERFILE" TO F.OTHER ELSE
CRT "Can't open OTHERFILE file to retrieve data from"
STOP
END

REM1 = 999
LOOP WHILE REM1 NE 0
REMOVE LINE FROM D.UFD SETTING REM1
K.OTHER = FIELD(LINE, TABCHAR, 1)
READ D.OTHER FROM F.OTHER, K.OTHER THEN
ONE = D.OTHER<1>
TWO = D.OTHER<2>
do something with the fields...
END ELSE
CRT "Cant' read record ": K.OTHER: " from OTHERFILE."
END
REPEAT
*
CRT "DONE"
STOP


-- 
Allen Egerton; aeger...@pobox.com


_______________________________________________
U2-Users mailing list
U2-Users@listserver.u2ug.org
http://listserver.u2ug.org/mailman/listinfo/u2-users

Reply via email to