Importação de arquivo CSV
Pessoal que pode me ajudar, estou tentando fazer importação de um arquivo CSV, que ocorrerá mensalmente no sistema, estou usando SQL como tabelas o código está a seguir, já fiz funcionar mas está danda problema não sei o que está ocorrendo. alguém sabe? ou outra forma de fazer isso.
procedure TImpNF.CustoMateriaPrimaClick(Sender: TObject);
var
Arq: TextFile;
Texto, Pla, Cod, Eco, Pre : string;
I : Integer;
function MV : String;
var
monta:String;
begin
monta:='';
inc(I);
while texto* <> '|' do { DEFINE O FINAL DA LINHA }*
begin
* if texto**= ';' then { DEFINE DIVISÃO DE CAMPOS DO ARQ A IMPORTAR }*
break;
* monta := monta + texto**;*
inc(I);
end;
result := monta;
end;
begin
if OpenDialog1.Execute then
begin
screen.Cursor:= crHourGlass;
AssignFile(Arq,OpenDialog1.FileName);
reset(Arq);
if not EOF(Arq) then
repeat
ReadLn(Arq,Texto);
with Cust_M_Prima do
begin
i:=0;
Label7.caption := mv;
Label8.caption := mv;
Label9.caption := mv;
if not Locate('Cad_CM_Planta',Label7.Caption,[]) and
not Locate('Cad_CM_Codigo',Label8.Caption,[]) and
not Locate('Cad_CM_Economics',Label9.Caption,[]) then
begin
Append;
FieldByName('Cad_CM_Planta').AsString := mv;
FieldByName('Cad_CM_Codigo').asString := mv;
FieldByName('Cad_CM_Economics').AsString := mv;
FieldByName('Cad_CM_Preco').asString := mv;
Post;
end;
end;
until EOF(Arq);
end;
CloseFile(Arq);
Cad_MPrima.Close;
Screen.Cursor:= crDefault;
end;
Discussão (8)
Carregando comentários...