Arquivo texto
tenho um arquivo texto neste padrão:
a
b
c
d
e
f
e preciso deixá-lo assim:
a; b; c;
d; e; f;
qual a melhor maneira de se fazer isso? tentei puxar em um memo mas não sei como concatenar duas linha em uma, exemplo: a;b;
Alguém pode me ajudar?
a
b
c
d
e
f
e preciso deixá-lo assim:
a; b; c;
d; e; f;
qual a melhor maneira de se fazer isso? tentei puxar em um memo mas não sei como concatenar duas linha em uma, exemplo: a;b;
Alguém pode me ajudar?
Roberto Rossi
Curtidas 0
Respostas
Rjun
17/05/2006
O espaço em branco seria um separador? Você poderia usar uma stringlist.
var ArquivoEntrada: TStringList; ArquivoSaida: TStringList; Linha: string; i: integer; begin ArquivoEntrada := TStringList.Create; ArquivoSaida := TSTringList.Create; try Linha := ´´; ArquivoEntrada.LoadFromFile(´c:\Entrada.txt´); for i := 0 to ArquivoEntrada.Count - 1 do begin if (ArquivoEntrada.Strings[i] = ´´) then begin ArquivoSaida.Add(Linha); Linha := ´´; end else begin Linha := Linha + ArquivoEntrada[i] + ´;´; end; end; if (Linha <> ´´) then ArquivoSaida.Add(Linha); ArquivoSaida.SaveToFile(´c:\Saida.txt´); finally FreeAndNil(ArquivoEntrada); FreeAndNil(ArquivoSaida); end; end;
GOSTEI 0