[EMAIL PROTECTED] (Jim Kleckner) writes:
    I saw from an earlier post that the Reader actor is not
    normally made visible in the Vergil list of actors.
    It seems very useful to bring tab or comma separated
    data into the computation.  What would be the recommended
    way to do this?
----
The DoubleReader actor is visible under actor library -> io

Here are the docs:
--start--
This actor reads tokens from an URL, and output them. Each entry in
the file corresponds to one iteration. If there are multiple fires in
the iteration, the same token will be repeated. This actor has a
multiport, where each port corresponds to one column in the data file.
The file format at the URL is assumed as the following. A newline
character separates the rows, and a tab or a space character separates
the columns.

The sourceURL parameter should be set to the name of the file,
specified as a fully qualified URL. If the sourceURL parameter is an
empty string, then the System.in is used for input. It is possible to
load a file from the local file system by using the prefix "file://"
instead of "http://";. Relative file paths are allowed. To specify a
file relative to the current directory, use "../" or "./". For
example, if the current directory contains a file called "test.txt",
then sourceURL should be set to "file:./test.txt". If the parent
directory contains a file called "test.txt", then sourceURL should be
set to "file:../test.txt". To reference the file test.txt, located at
"/tmp/test.txt", sourceURL should be set to "file:///tmp/test.txt" The
default value is "file:///tmp/test.txt".

FIXME: The type of the output ports is set to Double for now. It
should read a line in the prefire() and refer the type from there.
FIXME: Reader should read in expressions and serialized tokens
--end--

There is also the readFile and readMatrix expression operators, see
http://ptolemy.eecs.berkeley.edu/ptolemyII/ptII2.0/ptII2.0.1/doc/expressions.htm

I believe that the way to use readFile is as an expression:
eval(readFile("foo.txt"))

How we read in values from files needs to be revamped, we could do more with
interpreting the file contents as expressions or as serialized data.

-Christopher


----------------------------------------------------------------------------
Posted to the ptolemy-hackers mailing list.  Please send administrative
mail for this list to: [EMAIL PROTECTED]

Reply via email to