Board index » delphi » Read a text file and write to a Dbase file

Read a text file and write to a Dbase file

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 (in other words how to
switch between the two files).  Any help on this would
be greatly appreciated.

Alan Bell (belalan @cam.org)

 

Re:Read a text file and write to a Dbase file


Do you mean a DBase table, is that what is meant by file?  I wrote a small
program that I needed to run just once for that exact same thing and if
you'd like I can e-mail the source code to you.

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

news:81tt6b$64o@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 (in other words how to
> switch between the two files).  Any help on this would
> be greatly appreciated.

> Alan Bell (belalan @cam.org)

Re:Read a text file and write to a Dbase file


Quote
In article <81tt6b$...@tandem.CAM.ORG>, "Alan Bell" <bela...@cam.org> writes:
> 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 (in other words how to
>switch between the two files).  Any help on this would
>be greatly appreciated.

Your easiest method would be to write a schema file defining the records of
your text file into fields (they should have the same name as your dBASE table
fields). Then place two TTables on a form, using one for the Text file and
another for the dBASE file, with their TDataSources. Then open them both and
code :-

MyDBaseTable.BatchMove(MyTextTable, batAppend);

... and that will append all the records to your dBase table. E-mail me with
details (and a short chunk) of your text file, and your dbase table fields if
you don't know how to write the schema file.

It would be trivial to do this at the command prompt in dBase, but I expect you
know that already <g>

Alan Lloyd
alangll...@aol.com

Other Threads