Board index » delphi » Text File Read / Dbase file Write

Text File Read / Dbase file Write

Help

I would like to know how I can open a text file with fixed length records,
read the fields and then write the data read into a Dbase file. I currently
have the code written to sequentially process the text file but I am at a
loss as to how to open the dbase file, write to the required fields and then
return to the text file to process the next record.  Any help on this would
be greatly appreciated.

Alan Bell (belalan @cam.org)

 

Re:Text File Read / Dbase file Write


BDE supplies a "text file" database driver that can be used to access a
fixed-format flat file as though it were a database table.

There are also utilities, like DataPump on the Delphi CD (not sure which
ones...) that can move data back and forth.

Finally, utilities like Data Junction and Cambio can be used to handle
more sophisticated data-swabbing tasks.  For example, Cambio can parse a
report-file that was "printed" to disk and collect information from it.

Should you need for some reason to write a program to do this, the
program itself is simply a loop...
        while not Eof(textfile) do begin
          Read(textfile, myrecord);
          table.Append;
          table.field1 := myrecord.textfield1;
          table.field2 := StrtoInt(myrecord.textfield2);
          table1.post;
          application.processmessages;
        end;

etc.

Quote
>Alan Bell wrote:

> Help

> I would like to know how I can open a text file with fixed length records,
> read the fields and then write the data read into a Dbase file. I currently
> have the code written to sequentially process the text file but I am at a
> loss as to how to open the dbase file, write to the required fields and then
> return to the text file to process the next record.  Any help on this would
> be greatly appreciated.

----------------------------------------------------------------------
Sundial Services :: Scottsdale, AZ (USA) :: (480) 946-8259
mailto:i...@sundialservices.com  (PGP public key available.)
Quote
> High-speed, script-driven, table repair/support for Paradox/BDE...
> ChimneySweep{tm}:  "Click click, it's fixed!" {tm}
> http://www.sundialservices.com/cs3web.htm

Re:Text File Read / Dbase file Write


Quote
Alan Bell <bela...@cam.org> wrote in message

news:81mhds$h7p@tandem.CAM.ORG...

Quote
> Help

> I would like to know how I can open a text file with fixed length records,
> read the fields and then write the data read into a Dbase file. I
currently
> have the code written to sequentially process the text file but I am at a
> loss as to how to open the dbase file, write to the required fields and
then
> return to the text file to process the next record.  Any help on this
would
> be greatly appreciated.

table1.open;
while not fileeof on sequential file
  read text file
  table1.insert;
  table1.fieldbyname('field1').value := textfield1;
  etc.
 table1.post;
end;
table1.close;
showmessage('all done');
Quote
> Alan Bell (belalan @cam.org)

Other Threads