Trying to make a comparison of two text files ("old" and "new", lines in the files are not in the same order in both files) and extracting into two new files ("bajas" and "novedades") the news lines in one of them and the disapeered lines in the other, i make it with filereadline like this:
$FicheroViejo = FileOpen($NFicheroViejo, 0)
If $FicheroViejo = -1 Then
MsgBox(0, "Error", "Imposible abrir el fichero " & $NFicheroViejo)
Exit
EndIf
$aCodViejo[0]=""
While 1 And Ubound($aCodViejo)<1000
$sLinea = FileReadLine($FicheroViejo)
If @error = -1 Then
ExitLoop
MsgBox(0, "Error leyendo la linea siguiente:", $sLinea)
EndIf
$SeparaenTrozos=StringSplit($sLinea,"|",1)
if $aCodViejo[0]="" then
$aCodViejo[0]=$SeparaenTrozos[5]
Else
_ArrayAdd ( $aCodViejo, $SeparaenTrozos[5] )
EndIf
GUICtrlSetData ( $LFicheroViejo, "Leyendo Viejos: " & String(UBound($aCodViejo)))
If @error = 1 Then
ExitLoop
MsgBox(0, "Linea completa=", $sLinea)
EndIf
Wend
FileClose($FicheroViejo)
etc...
This is very slow (files are about 9000 lines) so I try to do reading the files into memory and then comparing :
$NFicheroViejo=GUICtrlRead ($AIFicheroViejo)
$NFicheroNuevo=GUICtrlRead ($AIFicheroNuevo)
if ($NFicheroViejo="Arrastra aquí el fichero viejo" or $NFicheroNuevo="Arrastra aquí el fichero nuevo") or $NFicheroViejo=$NFicheroNuevo Then
MsgBox(4096, "Atención", "Debes seleccionar fichero Viejo y fichero nuevo antes de procesar", 5)
Else
$aCodViejo[0]=""
If Not _FileReadToArray($NFicheroViejo,$aLineasViejo) Then
MsgBox(4096,"Error", "Error al leer: " &$NFicheroViejo& @error)
Exit
EndIf
For $iCont= 1 to $aLineasViejo[0]
$SeparaenTrozos=StringSplit($aLineasViejo[$iCont],"|",1)
if $aCodViejo[0]="" then
$aCodViejo[0]=$SeparaenTrozos[5]
Else
_ArrayAdd ( $aCodViejo, $SeparaenTrozos[5] )
EndIf
GUICtrlSetData ( $LFicheroViejo, "Leyendo Viejos: " & String(UBound($aCodViejo)))
Next
$aLineasNuevo=0
$aCodNuevo[0]=""
If Not _FileReadToArray($NFicheroNuevo,$aLineasNuevo) Then
MsgBox(4096,"Error", "Error al leer: " &$NFicheroNuevo& @error)
Exit
EndIf
For $iCont= 1 to $aLineasNuevo[0]
$SeparaenTrozos=StringSplit($aLineasNuevo[$iCont],"|",1)
if $aCodNuevo[0]="" then
$aCodNuevo[0]=$SeparaenTrozos[5]
Else
_ArrayAdd ( $aCodNuevo, $SeparaenTrozos[5] )
EndIf
GUICtrlSetData ( $LFicheroNuevo, "Leyendo Nuevos: " & String(UBound($aCodNuevo)))
Next
but this crash at about the record 8500 and i dont know why.
An example of the lines and why I separe it in pieces and make the comparation in the 5th piece of the line:
A07400|ACETILCISTEINA 100 MG/SOB 30 SOBRES SUSPENSION ORAL|2.05|01/05/2007|804666|FLUMIL INFANTIL 100MG/SOB 30 SOBRES GRANU SOL ORAL|2.59|
A07400|ACETILCISTEINA 100 MG/SOB 30 SOBRES SUSPENSION ORAL|2.05|01/05/2007|800474|ACETILC FARMASIERRA 100MG 30 SOB MON GRA SOL O EFG|2.05|EFG
A07400|ACETILCISTEINA 100 MG/SOB 30 SOBRES SUSPENSION ORAL|2.05|01/05/2007|730549|ACETILCISTEINA BEXAL 100MG/SOB 30 SOB EFG|2.05|EFG
A07400|ACETILCISTEINA 100 MG/SOB 30 SOBRES SUSPENSION ORAL|2.05|01/05/2007|851683|ACETILCISTEINA MERCK 100MG GRANUL SOL ORAL 30 EFG|2.05|EFG
A07400|ACETILCISTEINA 100 MG/SOB 30 SOBRES SUSPENSION ORAL|2.05|01/05/2007|650158|ACETILCISTEINA CINFAMED 100MG 30 SOBRES SOL OR EFG|2.06|EFG
A07400|ACETILCISTEINA 100 MG/SOB 30 SOBRES SUSPENSION ORAL|2.05|01/05/2007|653992|ACETILCISTEINA ACOST 100MG 30 SOB POLV SUSP OR EFG|1.81|EFG
A07400|ACETILCISTEINA 100 MG/SOB 30 SOBRES SUSPENSION ORAL|2.05|01/05/2007|653884|ACETILCISTEINA UR 100MG 30 SOBR POLVO SOL ORAL EFG|1.8|EFG
A07400|ACETILCISTEINA 100 MG/SOB 30 SOBRES SUSPENSION ORAL|2.05|01/05/2007|656241|ACETILCISTEINA NORMON 100MG 30 SOBR GR SO ORAL EFG|1.75|EFG
A07400|ACETILCISTEINA 100 MG/SOB 30 SOBRES SUSPENSION ORAL|2.05|01/05/2007|650429|ACETILCISTEINA CINFA 100MG 30 SOBRES SOL OR EFG|1.81|EFG
A07400|ACETILCISTEINA 100 MG/SOB 30 SOBRES SUSPENSION ORAL|2.05|01/05/2007|652631|ACETILCISTEINA ANGENERICO 100MG 30 SOB PO S OR EFG|1.81|EFG
A07400|ACETILCISTEINA 100 MG/SOB 30 SOBRES SUSPENSION ORAL|2.05|01/05/2007|773366|ACETILCISTEINA SANDOZ 100MG/SOB 30 SOB GRAN OR EFG|2.05|EFG
A07400|ACETILCISTEINA 100 MG/SOB 30 SOBRES SUSPENSION ORAL|2.05|01/05/2007|788919|ACETILCISTEINA TARBIS 100MG/SOB 30 SOB MONODOS EFG|1.81|EFG
Any ideas to help me?
(I excuse me for my english and the poor explication of the problem.)
Thank you very much