Access Keys:
Skip to content (Access Key - 0)
 
More about this article
Created: 11/07/2008 10:33
Modified: 02/25/2009 12:40

How do I input and output data using Maple?

The routines described here are best for raw data input and output. To save your Maple session or export data in a different format, please see "How can I save, restore and export information with Maple?". A brief description of each routine follows; use the online
help for more information.

Input

  • "readline" reads a single line from a file or the terminal, and returns it as a string. You can then parse this with "sscanf" or the "parse" function (for Maple expressions).
  • "readdata" reads a text file containing numbers separated by tabs or spaces, and returns it as a list. You can specify which columns to read, and whether to treat them as integers or floats.
  • "fscanf" "sscanf" and "scanf" are based on the C standard library functions of the same names for formatting input. The Maple versions of these functions each return a list.
  • "readbytes" reads a specified number of bytes from a file, and returns either a list of integers or a string of characters.

Output

  • "writeline" writes strings to a file or the terminal.
  • "writedata" is used to write numerical data to a text file.
  • "fprintf" "sprintf" and "printf" are based on the C standard library functions of the same names; these allow you to control the format of output. There is also an "nprintf" which returns a Maple symbol rather than a string.
  • "writebytes" writes the bytes from a string of characters or list of integers to a file (the file is opened with type text or binary, respectively).
Your Rating: Results: PatheticBadOKGoodOutstanding! 0 rates

Adaptavist Theme Builder Powered by Atlassian Confluence