readfile

readfile

Reads and stores one line of a file at a time into a string variable and continues looping through the file until the end of the file is reached.  A set of commands can be executed after each line is read into the assigned string variable.  Readfile is very useful during data collection applications where multiple lines of raw data are initially captured from the set device with the send or collect commands and written to a temporary file.  Once the data lines are safely stored in a temp file, each line can be parsed into individual variables to be written to a permanant data file and/or tested inside the readfile loop.

Attributes:

file: the path and file to be opened.  Default path is in local profile directory.
var: the variable in which to store each line
skipempty: True to skip over empty lines, False to read them. (default is true)

Example:

<readfile var="DataLine" file="myTextFile.txt" skipempty="True" >
    <write file="MyDataFile.txt" string="Raw data = [DataLine]" />
    <loadvars string="[DataLine]" type="text" vars="a,b,c" />
   <write file="MyDataFile.txt" string="Parsed data = [a],[b],[c]{10}{13}" />
</readfile>