|
 |
The
TextImporter object represents text data to be imported into a DataWeb application. Use the TextImporter object to import data from CSV (comma separated value) files, Excel files, and files with other data formats.
Constructor
TextImporter() |
Creates a new instance of a TextImporter object. |
|
Instance Properties
fields |
The fields property is an array of objects representing the fields in the source document. Each member of the array has three properties: name, import, and type. The name property gives the name of the field, the import property indicates whether or not to import the field from the source file, and type gives the data type of the field (e.g., "Text", "True/False", etc.). |
Warnings |
Check the value of this property for any warnings concerning the data within the TextImporter object after calling loadTextFile() or loadText(). |
Errors |
Check the value of this property for any errors concerning the data within the TextImporter object after calling loadTextFile() or loadText(). |
|
Instance Methods
loadTextFile |
Reads data from a file in the web application and loads it into the calling TextImporter object. |
loadText |
Parses data according to specified parameters and loads it into the calling TextImporter object. |
set |
Modifies data in a TextImporter object. |
get |
Retrieves data from the calling TextImporter object. |
guessTypes |
Fills in the values of the fields array based on a best guess about the kind of data contained in the source document. |
createTable |
Creates a data table based on a TextImporter object. |
appendTable |
Adds data from a TextImporter object to a data table. |
|
Example
/*
* Assume a csv file named "tiTest.csv" (located at the root directory of a web
* application) whose first row indicates four fields:
* FirstName, LastName, Email, Address
*/
var ti = new TextImporter();
ti.loadTextFile("/tiTest.csv", TRUE, "csv");
for(var prop in ti)
response.write(prop, "<br>");
response.write("--------<br>");
for(var prop in ti.fields)
response.write(ti.fields[prop].name, ",", ti.fields[prop].type, "<br>");
/*
* output:
*
* fields
* Errors
* Warnings
* --------
* FirstName,Text
* LastName,Text
* Email,Text
* Address,Text
*
*/
|