ParseFile - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Online Help

All Products    Maple    MapleSim


YAML

  

ParseFile

  

read YAML data from a file

 

Calling Sequence

Parameters

Options

Description

Examples

Compatibility

Calling Sequence

ParseFile(source, opts)

Parameters

source

-

string; file or URL to read from

opts

-

(optional) options as specified below

Options

• 

array : list or Array

  

Specifies the data struscture to use for parsed data corresponding to YAML arrays (sequential data delimited with square brackets). With array=list (the default), a YAML array is encoded as a list; with array=Array, it is encoded as an Array.

• 

object : one of table, record, or DataSeries

  

Specifies the data structure to use for parsed data corresponding to YAML objects (collections of key/value pairs delimited with curly braces).

  

With object=table (the default), an object is encoded as table; with object=record, it is encoded as a record; with object=DataSeries, it is encoded as a DataSeries.

• 

output : one of table, record, or DataSeries

  

A legacy alias for the object option.

Description

• 

ParseFile(source) 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

addressFileTools:-JoinPathexample/address.yaml,base=datadir:

YAML:-ParseFileaddress

tablecompanyName=Maplesoft,founded=1988,phoneNumbers=tablenumber=+1 (519) 747-2373,type=local,tablenumber=+1 (800) 267-6583,type=toll-free,tablenumber=+1 (519) 747-5284,type=fax,address=tablestreetAddress=615 Kumpf Drive,city=Waterloo,province=ON,postalCode=N2V 1K8,country=Canada

(1)

Parse the same input YAML file to a Maple record

YAML:-ParseFileaddress,object=record

RecordpackedcompanyName=Maplesoft,founded=1988,phoneNumbers=Recordpacked...,Recordpacked...,Recordpacked...,address=Recordpacked...

(2)

Compatibility

• 

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

• 

For more information on Maple 2017 changes, see Updates in Maple 2017.

• 

The YAML[ParseFile] command was updated in Maple 2022.

• 

The array and object options were introduced in Maple 2022.

• 

For more information on Maple 2022 changes, see Updates in Maple 2022.

See Also

YAML

YAML[ParseString]

YAML[ToString]