Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Import Data from a .dat file

Status
Not open for further replies.

sopomeres

MIS
Jan 16, 2003
61
US
(I'm using FoxPro 6.0. )

I have a table called students.dbf and would like to have data imported from a DAT file called 'fullup.dat'.

There are 2 fields in the DAT file... An 'id' field (unique identifier) field and a 'mealcode' field. I would like to create a job to have a scheduled 'import' from the 'fullup.dat' file into the 'students.dbf' table and where the data in the 'mealcode' field is overwritten each time.

Any idea?

Thank you.
Chuck
 
.DAT files are not a real standard format - many applications use them (DataFlex and MapInfo come to mind).

What created your .DAT files, and is there a documented format for it? Is it all text, or is there "binary" data in it?

Rick
 
Rick,

The .DAT file is automatically generated and exported from another app. The fields in the destintaion file, student.dbf, are both text strings, but in the DAT file they are double ints. Should I request that the export file have the data saved as text? Also, is there a preferable file type to import into FoxPro?

Thank you.
Chuck
 
Chuck,
Yes, since this app isn't "standard", using a straight text file will make a data import much easier. Now you'll have to find out whether it's in SDF (fixed width fields) or "delimited" format.

Look at the APPEND FROM Command, and the IMPORT Command in the Help file to see some of your options, and restrictions. Note: If you know the internal format / structure of a file, you can use low-level I/O to read most anything. Of course this usually requires some parsing and conversion of the data to get it so you can then put it into your .DBF, but it is always an option.

Rick
 
Does FoxPro have some macro-type utility to schedule a job? I have no idea on how to automate an import job in FoxPro.

 
No, VFP doesn't do anything "automatic", it's a developers environment, and you need to code for what you want it to do.

Normally if I need to run something on a regular basis, I'll use the Windows Scheduler to fire up the task, and have VFP do what it needs to and then quit.

Rick
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top