Search these areas:
Support Forums
Product Info

DataWeb: What's New
Creating an Application
The DataWeb Designer
Application Management
Data Tables
Data Tables
Data Analysis
Object Model
JavaScript Objects
General Scripting Objects
Data Access Objects
cmdDelete Object
cmdInsert Object
cmdSelect Object
cmdUpdate Object
Data Access Method Arguments
Field Object
Fields Collection
Index Object
Indexes Collection
previous Object
record Object
Resultset Object
Table Object
Tables Collection
TextImporter Object
Settings Object
View Object
Web Object
File Access Objects
Http Client Objects
Security and Membership Objects
Document Object Model (DOM)
Error Descriptions
Object Model Extensions
Full-Text Search
Domain and Email Hosting
HotBlock Modules
Account Management
New Responsive UI Module

DataWeb Help
Support Forums
Script Library
Knowledge Base

Home > Support

DataWeb User's Guide


TextImporterInstance.loadTextFile(filePath, FieldsBoolean [, dataFormat, [parserArguments]])

Arguments Description
filePath The string parameter filePath specifies the full path of the source document containing the data to be imported.
FieldsBoolean The Boolean parameter FieldBoolean specifies whether or not the source document contains fields names in the first row. If FieldBoolean is TRUE, then the first row of data is used to determine the field names. If FieldBoolean is set to FALSE, then the fields are automatically named Field1, Field2, etc.
dataFormat The optional string parameter dataFormat specifies the formatting of the source data. The default value is "csv". To specify a different format, give this parameter the value "delimited", and then provide formatting details in the fourth parameter, parserArguments.
parserArguments The parserArguments parameter takes an object with four properties: field, row, quote, escapedQuote. The value of field indicates how your source document delimits the field values, the value of row indicates how your source document delimits the different rows, the value of quote indicates the character the source document uses to deliniate strings, and the value of escapedQuote indicates how the source document escapes the character used to deliniate strings. See the examples below for specific data formats.

Note: if a row delimiter is specified to be any new-line delimiter ('\r', '\n', '\r\n', or '\n\r',) the parser assumes that all such new-line delimiters indicate the end of a row. The allows the user to simply specify '\n' as their line delimiter with consistent behavior, despite the fact that UNIX, Mac, and Windows platforms all use different combinations of new-line characters.




Parses the source data according to the parameters supplied. The parsed data is placed into the TextImporter instance, and its property, fields, is populated, either with names parsed from the data or default field names (Field1, Field2, etc.), depending on the FieldsBoolean parameter. Each field's type property is populated with a guess based on the first 20 rows of data. Each field's import property is set to true.


The example below illustrates importing data from a CSV (comma separated values) file. Note that in CSV files: field values are delimited with a comma (,), rows are delimited with the carriage return symbol followed by the new line character (\r\n), string data is delimited with double quotes ("), and double quotes within text data escaped with two double-quotes (""). However, since loadTextFile() defaults to the settings for a CSV file, the last two parameters can be left out entirely when importing a CSV file. I have explicitly included the last two parameters below for the purposes of exposition.

var ti = new TextImporter();
ti.loadTextFile("/myData.csv", TRUE, "csv", {field:',', row:'\r\n', quote:'"', escapedQuote:'""'});
   // ti.loadTextFile("/myData.csv", TRUE); 
   // will have the same effect as 
   // ti.loadTextFile("/myData.csv", TRUE, "csv", {field:',', row:'\r\n', quote:'"', escapedQuote:'""'});
   // since the method loadTextFile() defaults to the settings for a CSV file.

   //The following example illustrates the settings for tab delimited data.
var ti2 = new TextImporter();
ti2.loadTextFile("/myData.txt", TRUE, "delimited", {field:'\t', row:'\r\n', quote:'"', escapedQuote:'""'});
Affiliate | Partner | Terms of Use | Privacy Policy | Contact Us | Pricing | Bring DataWeb In-House    
Email Us