Fórum Comparar 2 arquivos Texto com o mesmo Layout #296604
22/09/2005
0
Se no Arquivo1 existir alguma linha que não exista no Arquivo2, então criar um Arquivo3.txt contendo essas linhas.
Fabiano Góes
Curtir tópico
+ 0Posts
22/09/2005
Bmetric
Gostei + 0
22/09/2005
Fabiano Góes
Gostei + 0
22/09/2005
Bmetric
var f:TextFile; SL:TStringList; s:String; begin SL := TStringList.Create; try SL.LoadFromFile(´c:\Arq2.txt´); AssignFile(f, ´c:\Arq1.txt´); Reset(f); While not Eof(f) do begin Readln(f, s); if SL.IndexOf(s) < 0 then begin // Arq1 não existe em Arq2 end; end; CloseFile(f); finally SL.Free; end; end;
Gostei + 0
22/09/2005
Fabiano Góes
exatamente o que eu precisava !!!!!!
:lol:
Gostei + 0
22/09/2005
Rjun
var Base, AComparar, Resultado: TStringList; i: integer; begin Base := TStringList.Create; AComparar := TStringList.Create; Resultado := TStringList.Create; try Base.LoadFromFile(´c:\Arq2.txt´); AComparar.LoadFromFile(´c:\Arq1txt´); for i := 0 to AComparar.Count do if Base.IndexOf(AComparar.Strings[i]) < 0 then Resultados.Strings.Add(Base.Strings[i]); Resultados.SaveToFile(´c:\arquivoerros.txt´); finally FreeAndNil(Base); FreeAndNil(AComparar); FreeAndNil(Resultado); end;
Gostei + 0
22/09/2005
Fabiano Góes
Cara estou achando muito legal o que se pode fazer com TStringList.
a propósito se você tiver alguns exemplos de Utilização de TStringList epuder me mandar eu agradeceria muito . :lol:
fabianogoes@ig.com.br
de qualquer forma você já me ajudou muito !!!!!
Gostei + 0
22/09/2005
Bmetric
for i := 0 to AComparar.Count do
Gostei + 0
22/09/2005
Rjun
for i := 0 to AComparar.Count do
Verdade. O correto é :
for i := 0 to AComparar.Count -1 do
Gostei + 0
22/09/2005
Rjun
for i := 0 to AComparar.Count do
Não se sinta encabulado para postar a correção.
Gostei + 0
22/09/2005
Bmetric
Duplicates, CaseSensitive.
Gostei + 0
23/09/2005
Fabiano Góes
for i := 0 to AComparar.Count -1 do
Valeu a atenção pessoal :wink:
Gostei + 0
23/09/2005
Fabiano Góes
var Entrada, Saida, Resultado : TStringList; i : Integer; begin Entrada := TStringList.Create; Saida := TStringList.Create; Resultado := TStringList.Create; Entrada.LoadFromFile(´c:\arqEnt.txt´); Saida.LoadFromFile(´c:\arqSai.txt´); for i := 0 to Entrada.Count - 1 do begin if saida.IndexOf(Entrada.Strings[i]) < 0 then Resultado.Add(Entrada.Strings[i]); end; Resultado.SaveToFile(´c:\NProces.txt´);
deixando os creditos aos colegas( Rjun, bmetric ) é claro !!
valeu brothers
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)