datafiles.htmlTEXTMPad ʵeeq MathPad Manual _ Data Files

Data Files

MathPad provides read and write functions for saving results and for importing or exporting data.

The function read("filename") returns an array of values read from the named data file. The data file is assumed to be in the same folder as the source document. Mac style pathnames such as "Hard Disk:DataFolder:file47" are allowed. Aliases for data files are resolved. Aliased folders within the pathname, however, are not allowed.

Each read function supports a single data file for each evaluation of the document. The entire array is read in the first time any element is accessed. Changing the file name after the file is read in will have no effect.

The function write("filename",array) writes the elements of the 1D or 2D array to the named file.

There are three data file formats supported: Text files, 32-bit floating point and 16-bit integer. The Options... dialog allows you to select which format will be written. The read function can read any of the three formats. It learns the format from the file's type.

TEXT format

TEXT data files can be written or read by many applications. MathPad's read function is very flexible about how the numbers are formatted and delimited. Commas, tabs, spaces, letters or anything except -.? or digits can be used to delimit numbers.

MathPad does assign some meaning to line formatting. The number of values in the first line is taken as the number of columns in the matrix. If the file consists of a single row or a single column of numbers it is treated as a one dimensional array rather than a matrix. If the file starts with a return (empty first line) then it is treated as a one dimensional array regardless of how the rest of the lines are formatted.

The write function uses a single tab to delimit each number. Matrix values are output as one row per line. This format is compatible with many spreadsheet programs. Numbers are written with 7 digit precision regardless of the current numeric format. A '?' is used to represent missing data.

The write function will write out strings for the special case of a 2D array of strings and a TEXT file. Each string is written out with no quotes or separators. A line in the output file corresponds to a row in the 2D array.

32-bit IEEE floating point format

It is inefficient in both time and file space to convert numbers to text. For large data files it may be better to read and write a more compact binary form. This format stores 4 bytes/element. The numbers are stored in the file's data fork. There is no header or other special formatting. Matrix column information is stored in the resource fork.

16-bit integer format

This format provides an even more compact representation. It is however limited to integers in the range -32767 to +32767. The value -32768 is used to represent missing data. This format stores 2 bytes/element. The numbers are stored in the file's data fork. There is no header or other special formatting. Matrix column information is stored in the resource fork. ddfd. A zoom box is implemented f DatafilesTEXTMPadhTEXTMPadhT lwindow. Convenience features: An online help file can be opened as a separate window. Long expressions can be continu ?5Ȯ*),(Monaco9Monaco9$hijddf3ZPRefSTR#&SPRF2$< font & size