`
Par2: Process ASCII file using DOS driver 1998-04-07 -- John Hickey Originally, I used the ASCII driver and it was taking a long time to import 1000 records. The problem was not the adding of the records, but the reading of the ASCII file! I decided to use the DOS driver to read the ASCII file in big chunks, and then parse it out. I defined a DOS file (DOSFILE) with one field (LINE) that was 20000 long. I then used the following code to parse it out: NN#=0 SET(DOSFILE,1) LOOP Next(DOSFILE) !Reads in 20000 characters IF ERROR() Then BREAK. LOOP !Begin Parse X#=instring('<13,10>',clip(DOS:Line),1,1) !Looks for Carriage Return/Line Feed IF ~X# ASC:Line=DOS:Line !If not found, it's a partial line nn#=1 !set a flag and Break !read in next DOS Line Else If ~nn# !if not a partial line ASC:Line='' !re-set ASC:Line End End nn#=0 !re-set partial line flag ASC:Line=clip(ASC:Line) & sub(DOS:Line,1,x#-1) !This is the actual ASC record now DOS:Line=sub(DOS:Line,x#+2,20000) !shortens the DOS line for next parse ! ! Printed November 21, 2024, 1:49 pm This article has been viewed/printed 35343 times. |