ARCHIVED: In dBase or FoxPro, how do I import an ASCII (text) file?

This content has been archived, and is no longer maintained by Indiana University. Information here may no longer be accurate, and links may no longer be available or reliable.

Note: The software discussed here is no longer in common use at IU, and UITS may no longer be able to verify this text's accuracy; additionally, the UITS Support Center may no longer have the materials needed to adequately support this software.

There are two good ways to import ASCII files to xBase language products like dBase, FoxPro, and Clipper, depending on whether the ASCII file is delimited or flat. Before you use the append commands described below, you must create a database to receive the incoming data. When creating the database, make sure it contains fields that correspond to the data contained in the ASCII file. Also, make sure that your dBase fields are long enough to accommodate the incoming file. UITS strongly recommends that you test this on a copy of your database until you are sure that it operates satisfactorily.

Delimited file

If the ASCII file is delimited, each field is set apart with certain symbols, for example, quotation marks and commas:

  "Flinstone","Fred","123 Slate Road","Bedrock","Prehistoria"
  "Rubble","Barney","127 Slate Road","Bedrock","Prehistoria"  

In this case, you can use the command:

  append from filename type delimited  

Replace filename with the name of your ASCII file.

If you used a delimiter other than quotes and commas, use the following command:

  append from filename type delimited with delimiter

Replace filename with the name of your ASCII file, and delimiter with the symbol that separates the fields in the file. By default, a comma is the delimiter.

Flat file

If your ASCII file is flat, with fixed record length, it will look something like this:

  Flinstone    Fred      123 Slate Road    Bedrock     Prehistoria
  Rubble       Barney    127 Slate Road    Bedrock     Prehistoria

In this case, you can use the command:

  append from filename type sdf

Replace filename with the name of your ASCII file. For this to work, the fields in the ASCII file must match the length and order of the fields defined in the database into which you are importing.

This is document aale in the Knowledge Base.
Last modified on 2018-01-18 09:04:31.