Functions > Reading and Writing Files > Text Files
  
Text Files
READTEXT("file", ["type", ["delimiter", colwidths, ["rowspec", ["colspec", [emptyfill, ["blankrows", [options]]]]]]])—Returns an array containing the data in file.
WRITETEXT("file", M, [rows, [cols, ["decsymb"]]])—Writes a tab delimited text file such as .txt or.dat from a specified matrix of values M.
* 
Remember that in order to execute, an expression in a PTC Mathcad worksheet must be an assignment or a request for evaluation, as in:
Arguments
file is a string containing the filename or the full pathname and filename. Non-absolute pathnames are relative to the current working directory.
type is a string that specifies the data format used in the file:
delimited—Data columns separated by a consistent delimiter (default).
fixed—Fixed-column-width data.
delimiter (required for type delimited, omitted otherwise) is the symbol to use as the delimiter. For tab, type "\t"; for backslash, type "\\"; for automatic detection, type "auto" (default).
colwidths (required for type fixed, omitted otherwise) is an n × 1 column vector specifying the number of characters in each fixed-width column, where n is the total number of columns in the datafile. If this argument is omitted, READTEXT reads in full lines.
rowspec (optional) is either a string in the form of n specifying a single row to read, or a string in the form of n-x specifying the range of rows (inclusive) to read, or a string in the form of n- specifying the start row only. If this argument is omitted, READTEXT reads in every row of the file.
colspec (optional) is either a string in the form of n specifying a single column to read, or a string in the form of n-x specifying the range of column (inclusive) to read, or a string in the form of n- specifying the start column only. If this argument is omitted, READTEXT reads in every column of the file.
* 
You can define a non-contiguous range for both rowspec and colspec. For example, to read row 1 through row 4 and row 7, specify "1–4,7" for rowspec.
emptyfill (optional) is a string, scalar, or NaN (default), which is substituted for missing entries in the data file.
blankrows (optional) is a string that specifies what to do when encountering a blank line:
skip—Skip the current line.
read—Read the blank line (default).
stop—Stop the reading process.
options (optional) is a 3 x 1 column vector structured from top to bottom as 'txtqual', 'decsymb', 'thousep':
txtqual (text qualifier)—You can specify double quotes (default), single quote, or none.
decsymb (decimal symbol)—You can specify either "," (comma) or "." (dot). Dot is the default.
thousep (thousands separator)—You can specify either "," (comma), "." (dot) or " " (space). Comma is the default.
M is a matrix of values to write to the specified file.
rows (optional) is either a scalar specifying the first row to write, or a string in the form of n-x specifying the range of rows (inclusive) to write. If this argument is omitted WRITETEXT writes out every row of the file.
cols (optional) is either a scalar specifying the first column to write, or a string in the form of n-x specifying the range of column (inclusive) to write. If this argument is omitted, WRITETEXT writes out every column of the file.
decsymb (optional) is the decimal symbol to use. You can specify either "," (comma) or "." (dot). Dot is the default.
* 
Both rows and cols are indices that start with 1. ORIGIN does not affect the behavior of READTEXT.
You can only omit optional arguments from the last argument and back. For example, in WRITETEXT you cannot omit rows and specify cols and decsymb. If rows is omitted, the value of cols will be used as rows.
When using READTEXT, you must assign the function to a variable, such as A:=READTEXT(...).