Export - Maple Help

Export

export data from Maple to a file

 Calling Sequence Export(dest, data, opts) Export(data, target=direct, opts)

Parameters

 dest - string; file path or URL of the data file data - data to be exported opts - (optional) the format options as described later

Options

 • base : one of bindir, currentdir, datadir, homedir, mapledir, tempdir, toolboxdir, or worksheetdir.
 The base option specifies a base directory. Any local file specified with dest will be interpreted as a relative path under this directory. For the meaning of each of these values, see kernelopts or interface.
 • encoding : one of text or binary
 Specifies whether the output should be encoded using a text or binary variant of the format. This option is only effective for the PLY and STL output formats. The default is binary.
 • format : string
 The format option specifies the export format to use. This must correspond to one of the supported export formats. If omitted, the export format is inferred from the file extension of dest.
 • target : one of file or direct
 The default target=file specifies that the data should be written to the file referenced by dest; target=direct means that the data will be exported to a string or ByteArray to be returned. Note that target=direct requires format to be provided explicitly.

Description

 • The Export command exports data from Maple to an external file or to a string or ByteArray in the specified file format.
 • When target=file (the default), the command writes the exported data to the file dest and returns a number showing the count of bytes written.
 • When target=direct, the data is exported to a string or ByteArray which is returned as output. Note that target=direct requires format to be provided explicitly.
 • For details about the types of input accepted by a particular output format, consult the documentation for that format.

Supported Formats

Examples

Export a plot to a JPEG file.

 > $\mathrm{Export}\left("sinefile.jpg",\mathrm{plot}\left(\mathrm{sin}\right),\mathrm{base}=\mathrm{homedir}\right)$
 ${24610}$ (1)

Export numeric data to a file in Comma-Separated Values (CSV) format.

 > $\mathrm{Export}\left("data.csv",\mathrm{LinearAlgebra}:-\mathrm{RandomMatrix}\left(50,2\right),\mathrm{base}=\mathrm{homedir}\right)$
 ${334}$ (2)

Export data directly to a string in the JSON format with target=direct.

 > $\mathrm{PersonData}≔\mathrm{Record}\left(\mathrm{surname}="Turing",\mathrm{firstname}="Alan",\mathrm{birth}="1912-06-23",\mathrm{death}="1954-06-07"\right)$
 ${\mathrm{PersonData}}{≔}{\mathrm{Record}}{}\left({\mathrm{surname}}{=}{"Turing"}{,}{\mathrm{firstname}}{=}{"Alan"}{,}{\mathrm{birth}}{=}{"1912-06-23"}{,}{\mathrm{death}}{=}{"1954-06-07"}\right)$ (3)
 > $\mathrm{Export}\left(\mathrm{PersonData},\mathrm{format}="JSON",\mathrm{target}=\mathrm{direct}\right)$
 ${"\left\{ "surname": "Turing", "firstname": "Alan", "birth": "1912-06-23", "death": "1954-06-07" \right\}"}$ (4)

Export the same data to a JSON file.

 > $\mathrm{Export}\left("turing.json",\mathrm{PersonData},\mathrm{base}=\mathrm{homedir}\right)$
 ${88}$ (5)

Compatibility

 • The Export command was introduced in Maple 2015.