APPEND FROM + Progress Bar

APPEND FROM + Progress Bar

Postby George » Fri Aug 06, 2010 7:19 pm

Seria posible utilizar un control "progress bar" durante un APPEND FROM?
Alguna sugerencia o codigo de alguien que lo haya implementado?

Gracias

George
George
 
Posts: 725
Joined: Tue Oct 18, 2005 6:49 pm

Re: APPEND FROM + Progress Bar

Postby Patricio Avalos Aguirre » Fri Aug 06, 2010 9:59 pm

Hola

Yo utilizo con un MsgRun..


Code: Select all  Expand view  RUN
    MsgRun( "Espere, importando ", "Usuario",;
                             { || __dbApp( cPath + "\"+cDbf, {},,,,,.F., "DBFCDX") } )


podrias hacerlo dentro del codeblock :-)
Saludos
Patricio

__________________________________________________________________
Version: Harbour 3.2.0dev (r1307082134),Compiler: Borland C++ 5.8.2 (32-bit)
PCode version: 0.3, FWH 13.2
http://www.sialm.cl
User avatar
Patricio Avalos Aguirre
 
Posts: 1060
Joined: Fri Oct 07, 2005 1:56 pm
Location: La Serena, Chile

Re: APPEND FROM + Progress Bar

Postby ronaldo » Sat Aug 07, 2010 12:06 am

Eu, utilizo desta forma:


APPEND FROM IMOVEL ;
FOR If(lNewFile,(oMtr1:nTotal:=Reccount(), Sysrefresh(), lNewFile:=.f.,.t. ), (nPercent1++,oMtr1:Set(nPercent1),SysRefresh(),.t. ) )
[b]Ronaldo Minacapelli[/b]
Sistemas, Hospedagem e Criação de WebSites
http://www.bazevani.com.br
User avatar
ronaldo
 
Posts: 139
Joined: Fri Nov 25, 2005 4:38 pm
Location: brasil

Re: APPEND FROM + Progress Bar

Postby George » Sat Aug 07, 2010 7:19 pm

Gracias Ronaldo y Patricio por su ayuda.
Creo cualquiera de las dos soluciones propuesta por ustedes me sirve.

Saludos

George
George
 
Posts: 725
Joined: Tue Oct 18, 2005 6:49 pm

Re: APPEND FROM + Progress Bar

Postby antolin » Mon Aug 09, 2010 9:49 am

Ronaldo,

Está muy ben. ¿Se podría utilizar un CodeBlock o llamara una funcción desde la clausula FOR?

Gracias
Peaaaaaso de foro...
FWH 2007 - xHarbour - BCC55
antolin
 
Posts: 498
Joined: Thu May 10, 2007 8:30 pm
Location: Sevilla

Re: APPEND FROM + Progress Bar

Postby George » Mon Aug 09, 2010 8:13 pm

Añadiendo un dialogo NOWAIT con el control METER, el siguiente codigo funciona:
Code: Select all  Expand view  RUN

     MsgRun(cMsgRun, "Creating Transactions file January 2010 [BETA 0.9]",;
             { || TransaJan2010() })

FUNCTION TransaJan2010()
    APPEND FROM "Jan2010.CSV" FOR  (nPercent1++, oMtr1:Set(nPercent1),  SysRefresh()  )  DELIMITED WITH (,)
RETURN (.T.)
 


El problema es que hice una prueba añadiendo cerca de 800,000 records con los siguientes resultados:
A) Sin el METER tarda 1.5 minutos
B) Con el METER tarda casi 7 minutos.

Habra algun otro modo de hacerlo o alguna otra sugerencia?

Saludos


George
George
 
Posts: 725
Joined: Tue Oct 18, 2005 6:49 pm

Re: APPEND FROM + Progress Bar

Postby Daniel Garcia-Gil » Mon Aug 09, 2010 8:27 pm

George..


Pueds intentar hacer el SysRefresh() cada "x" registros, por ejemplo 100, 200, 500 o 1000
User avatar
Daniel Garcia-Gil
 
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 pm
Location: Isla de Margarita

Re: APPEND FROM + Progress Bar

Postby George » Mon Aug 09, 2010 9:55 pm

Gracias Daniel por tu sugerencia.
Con el siguiente cambio en APPEND FROM se toma ahora cerca de 2 minutos lo cual es aceptable.

Code: Select all  Expand view  RUN

FUNCTION TransaJan2010(nPercent1, oMtr1)
    APPEND FROM "Jan2010.CSV" WHILE (nPercent1++, oMtr1:Set(nPercent1),  IIF( (nPercent1/1000 - int(nPercent1/1000)) = 0 , SysRefresh(), ), TRUE  )  DELIMITED WITH (,)
RETURN (.T.)
 


George
George
 
Posts: 725
Joined: Tue Oct 18, 2005 6:49 pm

Re: APPEND FROM + Progress Bar

Postby Enrrique Vertiz » Sat Feb 05, 2022 4:22 pm

Buen dia

Alguien tiene el ejemplo completo de como funciona un APPEND FROM con el PROGRESS BAR, trato de implementar el que aqui adjuntan pero no me sale bien, GRACIAS
Enrrique Vertiz Pitta
Lima-Peru
xHb 1.23.1026X, Fwh 24.09, BCC74, MySQL 8.0.X, SQLLIB 1.9m
Enrrique Vertiz
 
Posts: 541
Joined: Fri Oct 07, 2005 2:17 pm
Location: Lima - Peru

Re: APPEND FROM + Progress Bar

Postby George » Sat Feb 05, 2022 5:54 pm

Enrique aqui tienes un ejemplo de la implementación de la barra de progreso leyendo el CSV que está en el array.
Code: Select all  Expand view  RUN

#include "FIVEWIN.CH"

FUNCTION Main()
    LOCAL oDlg, oMeter, nActual := 0
    DEFINE BRUSH oBrush COLOR CLR_LGRAY
        DEFINE WINDOW oDlg ;
            TITLE "Reading CSV file in array";
            BRUSH oBrush;
            FROM 0,0 TO 20, 80

         @ 8, 10 METER oMeter VAR nActual TOTAL 100 OF oDlg SIZE 500, 30

    ACTIVATE WINDOW oDlg ON INIT ( oDlg:Center(), ReadCSV(oDlg, oMeter))


FUNCTION ReadCSV(oDlg, oMeter) 
    LOCAL cMsgRun := "Procedure in execution; please Wait...", cMsgArrayData := "Creating CSV array data; please wait..."
    LOCAL nStart := Seconds(), nEnd, aData := {}, cText := "", cMsgMemo := "Reading CSV data source; please wait..."

    //===================================================================================================================
    // STEP ONE: Read CSV File
    //===================================================================================================================
    cFileCSV = "your_file.csv"
    MsgRun(cMsgMemo, "Main",  { | | cText := fCSVMemo(cFileCSV) })
    Sysrefresh()

    //===================================================================================================================
    // STEP TWO:  Read each line and save the result in array aData
    //===================================================================================================================
    MsgRun(cMsgArrayData, "Main",  { | | aData := HB_ATokens( cText, Chr(1), .t., .t. ) })
    syswait(.05)
    Sysrefresh()

    ? "Total rows in array: ", len(aData), " ", "Delay (secs): ", (Seconds() - nStart)

    separate_fields_in_array(aData, oDlg, oMeter)


FUNCTION fCSVMemo(cFileCSV)
    cText := StrTran( MemoRead( cFileCSV ), CRLF, Chr(1) )
RETURN (cText)

FUNCTION separate_fields_in_array(aData, oDlg, oMeter)

    //=======================================================================================================================
    // STEP THREE: Separate fields in each line based in delimiters and save the info in Array
    //=======================================================================================================================
    nLenData := int(len(aData))
    nDivisor := int(nLenData/100)
    IIF( nDivisor < 1, nDivisor := 1,)
    oMeter:nTotal := nLenData
    oMeter:Set(0)

    AEval( aData, { |c,i| c := StrTran( c, Chr(1), CRLF ), aData[ i ] := HB_ATokens( c, ",", .t., .t. ), MyProgressBar(i, nDivisor, oMeter, oDlg) } )
    nSec4 := Second()
    oMeter:Set(nLenData)
    syswait(.05)
    Sysrefresh()


//================================================================================================================
FUNCTION MyProgressBar(i, nDivisor, oMeter, oDlg)
    IIF(i/nDivisor = int(i/nDivisor),;
        (oMeter:Set(i),sysrefresh()),)
RETURN (.T.)


 
George
 
Posts: 725
Joined: Tue Oct 18, 2005 6:49 pm

Re: APPEND FROM + Progress Bar

Postby Enrrique Vertiz » Sat Feb 05, 2022 7:35 pm

George

GRACIAS eso era lo que necesitaba !!! y es rapidisimo en comparacion con leer Excel
Enrrique Vertiz Pitta
Lima-Peru
xHb 1.23.1026X, Fwh 24.09, BCC74, MySQL 8.0.X, SQLLIB 1.9m
Enrrique Vertiz
 
Posts: 541
Joined: Fri Oct 07, 2005 2:17 pm
Location: Lima - Peru


Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 56 guests