4.4. Data from Text Files

EspressChart also allows you to retrieve data from flat text files. To add a text file as a data source, select the TXTFiles node in the Data Source Manager and click Add. A dialog will open prompting you to specify a display name, and the location of the text file that you would like to use.

Add Text Data Source Dialog

[Tip]Tip

The text file can be also retrieved from URL. To do so, enter the URL to the File text field. You have to enter a full URL with protocol etc. (for example: http://www.quadbase.com/textfile.txt).

After you have specified the information, click OK and the text source will appear under the TXTFiles node of the Data Source Manager window.

4.4.1. Formatting Requirements for Text Files

There are certain formatting requirements for the data within a text file in order for it to be read by EspressChart. Generally, data is expected to be in a form similar to the following:

String,date,decimal
Name,day,Volume
"John","1997-10-3",32.3
"John","1997-4-3",20.2
"Mary","1997-9-3",10.2
"Mary","1997-10-04",18.6
            

The above data file is a plain text file. The first row specifies the data types and the second row specifies the field names. The third row and on are the records. Every text file must consist of these three parts. There are four records, with three fields each in the example data file. The delimiter between the fields may be one of the following characters: ",", ";", or " " (that is a comma, semi-colon, or space). Each field may be put in quotes (single or double).

4.4.2. Data Types and Format for Text Files

In text data files, the data type is specified using a keyword. The following is a list of recognized keywords, and their corresponding JDBC type and Java type.

Data File Keywords (Not Case Sensitive)JDBC TypeJava Type in EspressChart
Boolean, logical, bitBITBoolean
tinyintTINYINTbyte
smallint, shortSMALLINTshort
int, integerINTEGERint
long, bigintBIGINTlong
floatFLOATdouble
realREALfloat
doubleDOUBLEdouble
numericNUMERICjava.math.BigDecimal
decimalDECIMALjava.math.BigDecimal
dateDATEjava.sql.Date
timeTIMEjava.sql.Time
timestampTIMESTAMPjava.sql.Timestamp
stringCHARString
varcharVARCHARString
longvarcharLONGVARCHARString

For certain data types, the data in a text file must be presented in a specific format. The following is a list of the data types that require specific formatting.

Data TypeFormatExample
Dateyyyy-mm-dd or yyyy-mm2001-06-12 or 2000-06
Timehh:mm:ss12:17:34
Timestampyyyy-mm-dd hh:mm:ss2001-06-12 12:17:34
Booleantrue/false, t/f, 1/0 (case insensitive)true

There is a sample text file included in the EspressChart installation. The file is located in the help/examples/DataSources/text directory of your installation and is called Sample.dat.