Fórum como converter arquivo texto #208392

22/01/2004

0

preciso converter um arquivo texto para uma base de dados
ex:
1,´--´,texto´,textoresumido´,valor,desconto,
10,´--´,texto´,textoresumido´,valor,desconto,
100,´--´,texto´,textoresumido´,valor,desconto,
preciso copirar os texto entra as vigulas


Roussenq

Roussenq

Responder

Posts

23/01/2004

Bilatto

8) Posso lhe mostrar como converter Txt para Paradox.
Qual base de dados você pretende usar ??


Responder

Gostei + 0

23/01/2004

Nigro

Como importar dados de um arquivo texto para uma Tabela
var
sArquivo: TextFile;
Entrada, sArq2: string;
iLinha: integer;
begin
tblCep.Open;
tblCepLoc.Open;
bCancelaImport := False;
AssignFile(sArquivo, FileNameEdit1.FileName);
sArq2 := After(´Cep_Loc.txt´,FileNameEdit1.FileName);

iLinha := 0;
if FileNameEdit1.FileName = ´C:\Download\Ceps\Cep_loc.txt´ then begin
// Arquivo de Localidades
RzProgressBar1.TotalParts := 0;
RzProgressBar1.TotalParts := NumLinhasArq(FileNameEdit1.FileName);

Reset(sArquivo);
Readln(sArquivo,Entrada);
while not Eoln(sArquivo) do begin
Inc(iLinha);
Readln(sArquivo,Entrada);

// 0 = Base Total e 2 = Inclusao
if (copy(Entrada,90,1) = ´0´) or (copy(Entrada,90,1) = ´2´) then
begin
tblCepLoc.Append;
tblCepLoc.FieldByName(´cep_ChvLocal´).AsString :=
copy(Entrada,1,6);
tblCepLoc.FieldByName(´cep_Cidade´).AsString :=
copy(Entrada,7,60);
tblCepLoc.FieldByName(´cep_UF´).AsString := copy(Entrada,75,2);
try
tblCepLoc.Post;
except
tblCepLoc.Cancel;
end;
end
else if (copy(Entrada,90,1) = ´1´) then begin // Exclusao
if tblCepLoc.Locate(´cep_ChvLocal´, copy(Entrada,1,6),
[loPartialKey]) then
tblCepLoc.Delete;
end
else if (copy(Entrada,90,1) = ´3´) then begin // Alteracao
if tblCepLoc.Locate(´cep_ChvLocal´, copy(Entrada,1,6),
[loPartialKey])
then begin
tblCepLoc.Edit;
tblCepLoc.FieldByName(´cep_Cidade´).AsString :=
copy(Entrada,7,60);
tblCepLoc.FieldByName(´cep_UF´).AsString :=
copy(Entrada,75,2);
end;
try
tblCepLoc.Post;
except
tblCepLoc.Cancel;
end;
end;
RzProgressBar1.PartsComplete := iLinha;
Application.ProcessMessages;
if bCancelaImport then
Break;
end;
CloseFile(sArquivo);
end;


Responder

Gostei + 0

Utilizamos cookies para fornecer uma melhor experiência para nossos usuários, consulte nossa política de privacidade.

Aceitar