arquivo texto
Ola Pessoal
Já procurei neste forum mas nã encontrei algo que resolvesse o
meu problema que é o seguinte:
tenho um arquivo texto mais o menos assim
<Emitente CNPJ=´00000000000000´ razao_social=´teste ltda´ Endereco=´R.das flores´ cep=´0000000´ Cidade=´SAO´ UF=´XX´ IE=´000000000´ fone=´(XX)XXXXXX´/>
Como fasso para pegar as informaçoes que estao entre aspas
e jogalas em variaveis?
Grato Claudio
Já procurei neste forum mas nã encontrei algo que resolvesse o
meu problema que é o seguinte:
tenho um arquivo texto mais o menos assim
<Emitente CNPJ=´00000000000000´ razao_social=´teste ltda´ Endereco=´R.das flores´ cep=´0000000´ Cidade=´SAO´ UF=´XX´ IE=´000000000´ fone=´(XX)XXXXXX´/>
Como fasso para pegar as informaçoes que estao entre aspas
e jogalas em variaveis?
Grato Claudio
Claudiocjr
Curtidas 0
Respostas
Cpd_arim
20/05/2005
cuscon:currency;
i:integer;
txt : textfile;
entrada : string;
begin
Assignfile(txt,´c:\peesatpe.txt´);//nome do arquivo texto
reset(txt);
while not eoln(txt) do
begin
readln(txt,entrada);
table1.insert;
table1filcod.Value:=copy(entrada,01,02); 01 //posição que inicia seu arquivo texto 02 tamanho do seu campo na tabela.
table1codpec.Value:=copy(entrada,03,22);
table1sitpec.Value:=copy(entrada,25,03);
table1codcla.Value:=copy(entrada,28,22);
table1qtdest.Value:=copy(entrada,50,07);
table1qtdand.Value:=copy(entrada,57,07);
table1qtddef.Value:=copy(entrada,64,07);
table1cusatu.Value:=copy(entrada,71,14);
table1cuscon.value:=copy(entrada,89,14);
table1cusicm.Value:=copy(entrada,107,11);
table1cusmoe.Value:=copy(entrada,125,11);
table1cusrep.Value:=copy(entrada,143,11);
table1atuand.Value:=copy(entrada,161,11);
table1conand.Value:=copy(entrada,179,11);
table1icmand.Value:=copy(entrada,197,11);
table1moeand.Value:=copy(entrada,215,11);
table1repand.Value:=copy(entrada,233,11);
table1prient.Value:=copy(entrada,251,08);
table1ultent.Value:=copy(entrada,259,08);
table1ultsai.Value:=copy(entrada,267,08);
table1ultaju.Value:=copy(entrada,275,08);
table1ultinv.Value:=copy(entrada,283,08);
table1ultcus.Value:=copy(entrada,291,08);
table1ultpre.Value:=copy(entrada,299,11);
table1girtot.Value:=copy(entrada,312,05);
table1girbru.Value:=copy(entrada,317,05);
table1girver.Value:=copy(entrada,322,05);
table1filcod.EditMask:=´0000´;
table1.Refresh;
end;
closefile(TXT);
Table1.First;
ProgressBar1.Max := Table1.RecordCount;
for i := 1 to Table1.RecordCount do
begin
Table1.Next;
ProgressBar1.Position := i;
end;
ProgressBar1.Position := 0;
end;
se não entendeu meu email é cpd_arim@hotmail.com
esou on line pelo msn.
i:integer;
txt : textfile;
entrada : string;
begin
Assignfile(txt,´c:\peesatpe.txt´);//nome do arquivo texto
reset(txt);
while not eoln(txt) do
begin
readln(txt,entrada);
table1.insert;
table1filcod.Value:=copy(entrada,01,02); 01 //posição que inicia seu arquivo texto 02 tamanho do seu campo na tabela.
table1codpec.Value:=copy(entrada,03,22);
table1sitpec.Value:=copy(entrada,25,03);
table1codcla.Value:=copy(entrada,28,22);
table1qtdest.Value:=copy(entrada,50,07);
table1qtdand.Value:=copy(entrada,57,07);
table1qtddef.Value:=copy(entrada,64,07);
table1cusatu.Value:=copy(entrada,71,14);
table1cuscon.value:=copy(entrada,89,14);
table1cusicm.Value:=copy(entrada,107,11);
table1cusmoe.Value:=copy(entrada,125,11);
table1cusrep.Value:=copy(entrada,143,11);
table1atuand.Value:=copy(entrada,161,11);
table1conand.Value:=copy(entrada,179,11);
table1icmand.Value:=copy(entrada,197,11);
table1moeand.Value:=copy(entrada,215,11);
table1repand.Value:=copy(entrada,233,11);
table1prient.Value:=copy(entrada,251,08);
table1ultent.Value:=copy(entrada,259,08);
table1ultsai.Value:=copy(entrada,267,08);
table1ultaju.Value:=copy(entrada,275,08);
table1ultinv.Value:=copy(entrada,283,08);
table1ultcus.Value:=copy(entrada,291,08);
table1ultpre.Value:=copy(entrada,299,11);
table1girtot.Value:=copy(entrada,312,05);
table1girbru.Value:=copy(entrada,317,05);
table1girver.Value:=copy(entrada,322,05);
table1filcod.EditMask:=´0000´;
table1.Refresh;
end;
closefile(TXT);
Table1.First;
ProgressBar1.Max := Table1.RecordCount;
for i := 1 to Table1.RecordCount do
begin
Table1.Next;
ProgressBar1.Position := i;
end;
ProgressBar1.Position := 0;
end;
se não entendeu meu email é cpd_arim@hotmail.com
esou on line pelo msn.
GOSTEI 0
Kotho
20/05/2005
Esse arquivo não é XML não???
GOSTEI 0
Claudiocjr
20/05/2005
Sim é um arquivo XML, mas já procurei neste forum e postei
um novo topico dizendo que tinha com o componente CLIENTDATASET
funciona mas não encontrei nada que me explicasse como
funciona, por isso tentei postar como arquivo texto, para
ver se tinha outra solução
Grato
Claudio
um novo topico dizendo que tinha com o componente CLIENTDATASET
funciona mas não encontrei nada que me explicasse como
funciona, por isso tentei postar como arquivo texto, para
ver se tinha outra solução
Grato
Claudio
GOSTEI 0
Kotho
20/05/2005
Coloque um ClientDataSet no Form
Clique na elipse da propriedade FileName, e escolha o arquivo XML.
Atribua true para Active...
Pronto... seu XML está acessível pelo ClientDataSet, como se fosse uma tabela de um banco de dados...
Clique na elipse da propriedade FileName, e escolha o arquivo XML.
Atribua true para Active...
Pronto... seu XML está acessível pelo ClientDataSet, como se fosse uma tabela de um banco de dados...
GOSTEI 0
Claudiocjr
20/05/2005
Grato pela colaboracao, mas da um erro de DataPacket
Grato
Claudio
Grato
Claudio
GOSTEI 0
Kotho
20/05/2005
me manda esse arquivo ( se for possível )... alessandro.goncalves@jshayeb.com.br
GOSTEI 0
Kotho
20/05/2005
Cara... na verdade eu não tenho experiência com XML... mas eu tenho um exemplo do Guinter aqui, e o estranho é que o formato que seu arquivo está não é, nem um XML puro, nem um XML transformado para ser lido por ClientDataSet...
O XML puro seria assim:
O transformado seria assim (que é parecido com o seu):
É preciso utilizar o utilitário XMLMapper para gerar um arquivo transitório entre o XML... esse arquivo tem a extensão XTR...
O XML puro seria assim:
<?xml version="1.0" standalone="yes"?> <root> <ALUNO> <MATR_ALUNO>1</MATR_ALUNO> <NOME_ALUNO>Guinther Pauli</NOME_ALUNO> </ALUNO> <ALUNO> <MATR_ALUNO>2</MATR_ALUNO> <NOME_ALUNO>Rudolfo Pauli</NOME_ALUNO> </ALUNO> <ALUNO> <MATR_ALUNO>3</MATR_ALUNO> <NOME_ALUNO>Teste</NOME_ALUNO> </ALUNO> <ALUNO> <MATR_ALUNO>4</MATR_ALUNO> <NOME_ALUNO>Ola</NOME_ALUNO> </ALUNO> </root>
O transformado seria assim (que é parecido com o seu):
<?xml version="1.0" standalone="yes" ?> <DATAPACKET Version="2.0"> <METADATA> <FIELDS> <FIELD attrname="MATR_ALUNO" fieldtype="string" WIDTH="4" /> <FIELD attrname="NOME_ALUNO" fieldtype="string" WIDTH="28" /> </FIELDS> <PARAMS /> </METADATA> <ROWDATA> <ROW MATR_ALUNO="1" NOME_ALUNO="Guinther Pauli" /> <ROW MATR_ALUNO="2" NOME_ALUNO="Rudolfo Pauli" /> <ROW MATR_ALUNO="3" NOME_ALUNO="Teste" /> <ROW MATR_ALUNO="4" NOME_ALUNO="Ola" /> </ROWDATA> </DATAPACKET>
É preciso utilizar o utilitário XMLMapper para gerar um arquivo transitório entre o XML... esse arquivo tem a extensão XTR...
GOSTEI 0