Export - Maple Programming 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

 • format : string corresponding to one of the supported export formats; if unspecified, then the 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.
 • The target option may be set to file or direct. The default target=file specifies that the data should be written to the file referenced by dest. In contrast target=direct specifies that the data will be 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{sinefile}≔\mathrm{FileTools}:-\mathrm{JoinPath}\left(\left["sineplot.jpg"\right],\mathrm{base}=\mathrm{homedir}\right)$
 ${"/Users/JohnSmith/sineplot.jpg"}$ (1)
 > $\mathrm{Export}\left(\mathrm{sinefile},\mathrm{plot}\left(\mathrm{sin}\right)\right)$
 ${24610}$ (2)

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

 > $\mathrm{csvfile}≔\mathrm{FileTools}:-\mathrm{JoinPath}\left(\left["data.csv"\right],\mathrm{base}=\mathrm{homedir}\right)$
 ${"/Users/JohnSmith/data.csv"}$ (3)
 > $\mathrm{Export}\left(\mathrm{csvfile},\mathrm{LinearAlgebra}:-\mathrm{RandomMatrix}\left(50,2\right)\right)$
 ${334}$ (4)

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)$ (5)
 > $\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\}"}$ (6)

Export the same data to a JSON file.

 > $\mathrm{jsonfile}≔\mathrm{FileTools}:-\mathrm{JoinPath}\left(\left["turing.json"\right],\mathrm{base}=\mathrm{homedir}\right)$
 ${"/Users/JohnSmith/turing.json"}$ (7)
 > $\mathrm{Export}\left(\mathrm{jsonfile},\mathrm{PersonData}\right)$
 ${88}$ (8)

Compatibility

 • The Export command was introduced in Maple 2015.