|
ImportASCII() 
Loads the contents of an ASCII text file into a
CAPITAL database table.
Syntax
ImportASCII(<cDBFInto>, <cFile>,
[<cType>] ) --> lSuccess
Arguments
<cDBFInfo> -->
The database table to load the ASCII data into. This must be a
valid DBF table recognised by CAPITAL and located in the current
company folder. Path information is not allowed.
<cFile> --> The name of the ASCII text
file to load. Path information should be included.
<cType> --> The ASCII file type or
delimiter used if the file is of CSV type. Values may include:
|
SDF
|
Standard Data
Format. The fields contained in the file are of fixed length
without delimiters.
|
|
DEL
|
The file is a
standard ASCII comma delimited text file where fields are enclosed
in double-quote marks and separated by commas. (Although
double-quote marks are optional.) Fields and records may be of
variable length.
|
|
TAB
|
Tab
delimited
|
|
" "
|
Each field is
delimited with a blank space. Fields and records may be of variable
length.
|
|
<x>
|
Where <x> is
the delimiter used. For example, to import a tab delimited ASCII
text file specify the delimiter as CHR(08). Fields and records may
be of variable length.
|
Returns
Returns logical TRUE is the file import was
successful.
Description
This function accepts three parameters: the first
is the database table to import into, the second is the ASCII text
file to load, and the third is the ASCII file type. If reading the
file fails a FALSE condition is returned.
This function is usually used in conjunction with
the CreateTable() function which creates a database (DBF) table for
importing into.
In order to correctly import date information
into a date field, the date information in the ASCII text file must
be in yyyymmdd format. If this is not the case, import the date
information into a character field and then reformat it using
CAPITAL Business Script.
Unless otherwise indicated CAPITAL assumes the
imported ASCII text file has the extension .TXT
SDF Text Format
Specifications
|
Character
fields
|
Padded with trailing
blanks
|
|
Date
fields
|
yyyymmdd
|
|
Numeric
fields
|
padded with
leading blanks or zeros
|
|
Field
separator
|
None
|
|
Record
separator
|
Carriage
return/line feed
|
|
End of file
marker
|
1A hex or
CHR(26)
|
Delimited Text
Format Specification
|
Character
fields
|
May be delimited
with trailing blanks truncated.
|
|
Date field
|
yyyymmdd
|
|
Numeric
fields
|
Leading zeros may be
truncated
|
|
Field
separator
|
comma (by default)
or specified character type.
|
|
Record
separator
|
Carriage return/line
feed
|
|
End of file
marker
|
1A hex or
CHR(26)
|
Example
* Create a database table containing two
fields that
* will hold the contents of the ASCII
file
Declare Flds Type Array
Declare Typs Type Array
Declare Lens Type Array
Declare Decs Type
Array
Flds := { "PARTNO",
"TITLE" }
Typs := { "C", "C"
}
Lens := { 25, 40
}
Decs := { 0, 0 }
CreateTable("Test",
Flds, Typs, Lens, Decs)
* Now import the ASCII
text file
ImportASCII("Test",
"C:\Temp\Parts.csv", "DEL")
____________________________
Related Topics
Business
Function List
ExportASCII()
|