DADiSP Worksheet Functions > Function Categories > Data Input/Output Functions > WRITETABLE

 

WRITETABLE

Purpose:

Writes a single or multi-column series to an ASCII (text) or CSV file.

Syntax:

WRITETABLE(

"filename", series, overwrite, startcol, collist, "delstr", "format", prec, header, verbose)

"filename"

-

A string. The name of file to write as a multi-column table. If no path is given, WRITETABLE writes the file in the current working directory.

series

-

Optional. A multi-column series, the data to write. Defaults to the series in the current Window.

overwrite

-

Optional. An integer. The file overwrite mode.

0:

prompt before overwriting file (default).

1:

overwrite file if it exists without prompting.

2:

append data to the specified file. 

startcol

-

Optional. An integer, the starting column. Defaults to 1.

collist  

-

Optional. List of integers terminated by -1 indicating which columns of data to accept. Defaults to -1, all columns.

"delstr"  

-

Optional. A string, the column delimiters (separators). Defaults to space (" ").

"format"

-

Optional. A string, the number format. Defaults to "%f", floating point values.

prec  

-

Optional. An integer, the digit precision. Defaults to –1, automatic.

header

-

Optional. An integer, prepend header text flag.

0:

do not prepend header (default).

1:

prepend series comment.

2:

prepend series units.

3:

prepend series comment and units. 

verbose

-

Optional. An integer, the display progress messages flag. Defaults to 1, display.

Example:

writetable("table.dat",ravel(gsin(100, 0.1, 10), 10))

 

puts the generated sine wave into an ASCII (text) file named table.dat without a header.

Example:

writetable("table.dat",ravel(0..14, 5), ",")

 

Produces the following comma separated file:

 

 0.000000,5.000000,10.000000

 1.000000,6.000000,11.000000

 2.000000,7.000000,12.000000

 3.000000,8.000000,13.000000

 4.000000,9.000000,14.000000

 

This is an example of a Comma Separated Variable or CSV file where the "," is the column delimiter.

Example:

writetable("table.dat",ravel(0..14, 5), " ","%4.4x")

 

Produces the following space separated file:

 

 0000 0005 000a

 0001 0006 000b

 0002 0007 000c

 0003 0008 000d

 0004 0009 000e

Remarks:

WRITETABLE writes one or more columns to an ASCII (i.e. human readable text form) data file. Although a comment and unit line can be included, it does not export a full header with complete series information as per the Export Utilites.

 

If collist is specified, the list must terminate with -1 to indicate the end of the list.

 

For Comma Separated Variable or CSV files,  use the "," as the column delimiter.

 

See SPRINTF for details on the optional format string. When specifying a format string, a delimiter string must precede the format string.

 

See READTABLE to read a multi-column ASCII or CSV file.

 

WRITETABLE can be abbreviated WRITET.

See Also:

EXPORTFILE

IMPORTFILE

READA

READB

READTABLE

SPRINTF

WRITEA

WRITEB