ParseFile - Maple Help

YAML

 ParseFile
 read YAML data from a file

 Calling Sequence ParseFile(source, opts)

Parameters

 source - string; file or URL to read from opts - (optional) options as specified below

Options

 • output=name

either table, record, or DataSeries. Specifies the data structure to use for parsed data corresponding to YAML objects (collections of key/value pairs). With output=table (the default), an object is encoded as table; with output=record, it is encoded as a record; with output=DataSeries, it is encoded as a DataSeries.

Description

 • The ParseFile(source) command reads YAML data from the file or URL source.
 If source is a file, it is closed after it is read.

Examples

Parse an input YAML file to a Maple table

 > $\mathrm{address}≔\mathrm{FileTools}:-\mathrm{JoinPath}\left(\left["example/address.yaml"\right],\mathrm{base}=\mathrm{datadir}\right):$
 > $\mathrm{YAML}:-\mathrm{ParseFile}\left(\mathrm{address}\right)$
 ${table}{}\left(\left[{"companyName"}{=}{"Maplesoft"}{,}{"address"}{=}{table}{}\left(\left[{"streetAddress"}{=}{"615 Kumpf Drive"}{,}{"province"}{=}{"ON"}{,}{"postalCode"}{=}{"N2V 1K8"}{,}{"city"}{=}{"Waterloo"}{,}{"country"}{=}{"Canada"}\right]\right){,}{"founded"}{=}{1988}{,}{"phoneNumbers"}{=}\left[{table}{}\left(\left[{"type"}{=}{"local"}{,}{"number"}{=}{"+1 \left(519\right) 747-2373"}\right]\right){,}{table}{}\left(\left[{"type"}{=}{"toll-free"}{,}{"number"}{=}{"+1 \left(800\right) 267-6583"}\right]\right){,}{table}{}\left(\left[{"type"}{=}{"fax"}{,}{"number"}{=}{"+1 \left(519\right) 747-5284"}\right]\right)\right]\right]\right)$ (1)

Parse the same input YAML file to a Maple record

 > $\mathrm{YAML}:-\mathrm{ParseFile}\left(\mathrm{address},\mathrm{output}=\mathrm{record}\right)$
 ${{\mathrm{Record}}}_{{\mathrm{packed}}}{}\left({\mathrm{companyName}}{=}{"Maplesoft"}{,}{\mathrm{address}}{=}{{\mathrm{Record}}}_{{\mathrm{packed}}}{}\left({\mathrm{...}}\right){,}{\mathrm{founded}}{=}{1988}{,}{\mathrm{phoneNumbers}}{=}\left[{{\mathrm{Record}}}_{{\mathrm{packed}}}{}\left({\mathrm{...}}\right){,}{{\mathrm{Record}}}_{{\mathrm{packed}}}{}\left({\mathrm{...}}\right){,}{{\mathrm{Record}}}_{{\mathrm{packed}}}{}\left({\mathrm{...}}\right)\right]\right)$ (2)

Compatibility

 • The YAML[ParseFile] command was introduced in Maple 2017.