Leer archivo Excel / lectura lenta

HMG en Español

Moderator: Rathinagiri

Tiger
Posts: 74
Joined: Mon Aug 31, 2015 11:28 am
Location: Taipei

Re: Leer archivo Excel / lectura lenta

Post by Tiger »

As Jimmy said the Array is much quicker ....
I try to write 1000 records to dbf , used Array it can save around 30 seconds ...

aExcel:={}
nRows:=oSheet:UsedRange:Rows:Count()
nColumns:=oSheet:UsedRange:Columns:Count()
FOR i := 1 TO nRows
AADD(aExcel,ARRAY(nColumns))
NEXT
cEnde := ZAHL2CHR(nColumns)
oSheet:Range("A1:"+cEnde+LTRIM(STR(nRows))):SELECT()
aExcel := oSheet:range( "A1:"+cEnde+LTRIM(STR(nRows))):value2
nRows := 2
DO WHILE nRows <= nTotalRows

codigo := Alltrim(ConvertData(aExcel[1][nRows]))
nombre := Alltrim(ConvertData(aExcel[2][nRows]))
costo := IF(ValType(xField:=aExcel[3][nRows])=="N",xField,0)
precio := IF(ValType(xField:=aExcel[4][nRows])=="N",xField,0)
.
.
.
.
jparada
Posts: 433
Joined: Fri Jan 23, 2009 5:18 pm

Re: Leer archivo Excel / lectura lenta

Post by jparada »

Hi,
Could you please take the time to write a complete example, I have problems with data types and other errors when I tried to try the example of Array proposed by Jimmy.

I appreciate your help.

Regards,
Javier
Tiger
Posts: 74
Joined: Mon Aug 31, 2015 11:28 am
Location: Taipei

Re: Leer archivo Excel / lectura lenta

Post by Tiger »

jparada wrote: Thu Dec 26, 2019 6:06 pm Hi,
Could you please take the time to write a complete example, I have problems with data types and other errors when I tried to try the example of Array proposed by Jimmy.

I appreciate your help.

Regards,
Javier
Please check the attached file ...
Attachments
ARRAY_TEST.zip
(439.2 KiB) Downloaded 201 times
User avatar
AUGE_OHR
Posts: 2117
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: Leer archivo Excel / lectura lenta

Post by AUGE_OHR »

hi,

i have check *.XLSx File.
the 4th Field PUBLICO have 12 Decimal so how do you store it :?:
is this your Problem ...
have fun
Jimmy
martingz
Posts: 408
Joined: Wed Nov 18, 2009 11:14 pm
Location: Mexico

Re: Leer archivo Excel / lectura lenta

Post by martingz »

Javier siempre he tenido ese problema de lectura , escritura hacia archivos de excel, cambie muchos de mis reportes a excel (los que se tardaban mas) a archivos CSV delimitados por comas, esos los lee excel y al cargarlos a otras bases de datos el tiempo que me ahorro es bastante

Por lo que pudimos ver el problema es la lectura escritura hacia excel, me tome la libertad de hacer unas pruebas con la lectura de el archivo de excel convertiod a csv y estos fueron los resultados

array to dbf 14
cells to dbf 51
csv to dbf 8


saludos
jparada
Posts: 433
Joined: Fri Jan 23, 2009 5:18 pm

Re: Leer archivo Excel / lectura lenta

Post by jparada »

hola,
Gracias a todos por su ayuda, gracias al ejemplo de @Tiger avancé con el tema del array y efectivamente ha sido más rápida la lectura, este es un procedimiento que necesito para actualizar precios, no es algo que utilice comúnmente, así que para mi ya es aceptable la velocidad obtenida.

Gracias por su tiempo y ayuda.

Feliz año 2020.

Saludos,
Javier
Post Reply