` Comment on an Icetips Article
Icetips - Templates, Tools & Utilities for Clarion Developers

Templates, Tools and Utilities
for Clarion Developers

Add a comment to an Icetips Article

Please add your comments to this article. Please note that you must provide both a name and a valid email address in order for us to publish your comment. Comments are moderated and are not visible until they have been approved. Spam is never approved!

Your Name:  
Email:  
Header text/Subject:  

Please enter your comment in the box below:

Back to article list   Search Articles     Add Comment     Printer friendly     Direct link  

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 ! ! ! END !End Parse END !End DOS loop I put this into a Processing Template and it works great. If you do that, you don't need the first five lines (or the last END); the processing template takes care of that for you. You only need the lines from "Begin Parse" to "End Parse". The increase in speed was quite dramatic!


Today is November 23, 2024, 3:34 am
This article has been viewed 35346 times.



Back to article list   Search Articles   Add Comment   Printer friendly

Login

User Name:

Password: