Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Append from - is it possible to add progress bar
Message
From
17/01/2001 16:56:10
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00450093
Message ID:
00464922
Views:
37
>Hi everyone,
>
>I just found out, that I need to update my database every month, e.g. do append from a text file with ~ 7 mln. records. Therefore I'm asking just one more time, how can I add a progress bar, but not slow down the perfomance significantly?
>

How about just SET TALK ON with a reasonably large SET ODOMETER setting? Perhaps that won't kill performance too badly.


>May be somebody already wrote simple to use Progress Bar for Append from text file...
>
>Thanks in advance.
>
>>>>I don't know in advance how many records I have in a file.
>>>
>>>Guess, take the total K of the file and guess how long a record might be. Or take the total, divide it by something like 100 or 1000 and then extract rows until you have that long of a string.
>>
>>>>I don't know in advance how many records I have in a file.
>>>
>>>Guess, take the total K of the file and guess how long a record might be. Or take the total, divide it by something like 100 or 1000 and then extract rows until you have that long of a string.
>>
>>Hi Mike,
>>
>>I've thought about it a little bit more, and I think, I found a simple and a quite elegant solution.
>>
>>Bellow is a pseudo untested code (write it from the top of the head):
>>
>>local lnSize, loTerm, lcTempFile, lcLongStr, lcStr, lnSizeRead
>>lnSize=fsize(lcTextFile) && or use adir
>>loTerm=newobject('thermometer', 'wg.vcx','','Appending',lnSize)
>>lcTempFile=gcTempPath+sys(15) && ? sys(2001)
>>fh=fopen(lcTextFile)
>>lnSizeRead=0
>>select WorkTable && Table in which we want append
>>do while !feof(fh)
>>   lcLongStr=''
>>   for i=1 to 500 && Quite low number, so Append should be almost instantanious
>>      if feof(fh)
>>         exit
>>     endif
>>     lcStr=fgets(fh,2000)
>>     lnSizeRead=lnSizeRead+len(lcStr)
>>     loTerm.update(lnSizeRead)
>>     lcLongStr=lcStr+chr(10)+chr(13)
>>   next
>>    =strtofile(rtrim(lcLongStr),lcTempFile)
>>    append from (lcTempFile) && should be quick
>>enddo
>>release loTerm
>>
>>This is the idea. The similar idea could be used for append from table. Divide number of records, say, by 1000 and do append for betwen(recno(),lnStart, lnFinsish) in a loop (You got the idea).
>>
>>Ok, what do you think?
Fred
Microsoft Visual FoxPro MVP

foxcentral.net
Previous
Reply
Map
View

Click here to load this message in the networking platform