V Import()


Import records from specified input file to the table.


Specify the required values in the Import dot variable, then use the following command:


Type: N ---- You use the Import Type Codes to specify the file format of the source file:

Export Format Type Code

Number: 0, Extension: .ASC, Character-Separated ASCII


Number: 1, Extension: .TBL, Table ASCII


Number: 2, Extension: .RTF, Rich Text Format (RTF)


Number: 3, Extension: .XLS, Microsoft Excel, Version 3.0


Number: 4, Extension: .XLS, Microsoft Excel, Version 4.0


Number: 5, Extension: .WKS, Lotus 1-2-3, Version 1.0/1A


Number: 6, Extension: .WK1, Lotus 1-2-3, Version 2.0


Number: 7, Extension: .WK3, Lotus 1-2-3, Version 3.0


Number: 8, Extension: .WRK, Lotus Symphony, Version 1.0


Number: 9, Extension: .WR1, Lotus Symphony, Version 2.0


Type C ---- Optional. Default = NONE. The data in the source file is often preceded by the field names. If the file does have field names, you can specify one of the following options:

"USE" = use field names
"IGNORE" = ignore field names

Type: C ---- The name of the file to be imported.


Type: C ---- The name you assign for the resulting table file.


Type: N ---- Optional. Default = 0. For ASCII-import and damaged table files to set the number of lines at the beginning of the source file that should be ignored.


Type: N ---- Optional. Default = 0. For ASCII-import and damaged table files to set the number of bytes at the beginning of the source file that should be ignored.

import.field_sep, import.rec_sep

Type: C ---- Define how the end of fields and records are denoted in the source file. These strings can include any characters, including the following special separator characters:

<CR> <LF>

Carriage return and line feed combination


Carriage return


Line feed


Escape Escape




Type: C ---- Specifies the character length (including spaces and carriage returns) of one record in a source file that is in ASCII table format.


Type: L ---- Specifies whether or not leading blanks should be imported along with the data.

.T. (TRUE) = Import leading blanks
.F. (FALSE) = Do not import leading blanks

Type: C ---- Specify the character in which fields in a character-separated file are enclosed. The import.text_qualifier parameter is used to specify the character in which fields in a character-separated file are enclosed. For example, if your import file looks like this: "Alpha Software","168 Middlesex Tpke","01803" you would specify " \" " as the Text Qualifier. (NOTE: The quote qualifier is prefixed with a \ to distinguish it from the enclosing quotes.) If the import file looks like this: 'Alpha Software','168 Middlesex Tpke','01803' you would specify "'" as the Text Qualifier. (A single quote between double quotes.) If the text is not enclosed in qualifiers, then specify a NULL string (e.g., "").


Type: N ---- Specifies how many fields are to be imported.

import.field1 ... import.fieldN

Type: C ---- Specify the field name, type, offset, width, and decimal values in a comma delimited string for each of the field(s) to be imported. Refer to the example below for the format. In the case of a table ASCII file, the offset is the starting position of the field. In the case of all other files, the offset if the field number. The field number starts with 0. i.e., for import.field1, the offset is 0.

The TABLE.IMPORT() method is a high-level utility function you use to import the records of a file of a different format into a new table file. Most parameters passed to import through the Import function variable correspond directly with the prompts and options appearing on the Import Builder.


This script imports a character separated ASCII file into the desired table.

filename = ui_get_file("File To Import","ASCII(*.asc)",
choice = ui_get_radio("Field Name Status",1,"use","ignore","none")
import.type = 0
import.names = choice
import.file = filename
import.db = "c:\a5\a_sports\cust_new.dbf"
import.skip_lines = 0
import.skip_bytes = 0
import.field_sep = ","
import.record_sep = "<CR><LF>"
import.record_len = 0
import.rem_blanks = .T.
import.text_qualifier = ""
import.fields = 5
import.field1 = "cust_id,c,0,8,0"
import.field2 = "salutation,c,1,11,0"
import.field3 = "first_name,c,2,19,0"
import.field4 = "last_name,c,3,19,0"
import.field5 = "home_phone,c,4,15,0"

See Also