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

Online Help

All Products    Maple    MapleSim


Import

import external data into Maple

 

Calling Sequence

Parameters

Options

Supported Output Values

Description

Supported Formats

Examples

Compatibility

Calling Sequence

Import(origin, opts)

Parameters

origin

-

string or ByteArray; file path or URL to a data file or the data itself

opts

-

(optional) the format, output, source, or base options as described below

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 parameter origin will be interpreted as a relative path under this directory.

  

For the meaning of each of these values, see kernelopts or interface.

• 

format : string

  

The format option specifies the import format to use. This must correspond to one of the supported import formats. If omitted, the import format is inferred from the file extension and/or MIME type of origin.

• 

labeltype : one of symbol or string

  

When output=DataFrame, this option specifies whether non-numeric row and column labels should be expressed as symbols or strings when constructing the DataFrame.

  

The default is symbol.

• 

output : symbol

  

This option specifies the desired method for representing the imported data in Maple. Supported values are summarized in the following table.

Supported Output Values

anything

Array

Audio

auto

boolean

boolean_function

ByteArray

DataFrame

DataSeries

function

Graph

Image

list

logical

Logic

Matrix

plot

string

table

Vector

Vector[column]

Vector[row]

 

 

  

The default is auto, which specifies that a suitable format should be automatically inferred from the format. To determine the default behavior and supported values of output for a particular format, consult the documentation for that format.

• 

plotoptions : list of equation

  

A list consisting of zero or more plot options described in plot,options. These are only applied if the output is a plot, and are otherwise ignored.

• 

source : one of file or direct

  

This specifies whether the parameter origin refers to a file or URL (value file) or from a string or ByteArray in memory (value direct). The default is file.

• 

title : string

  

A string descriptor for the imported object. May be used by any of the import routines as a caption or title in the imported object. Supersedes any title provided in plotoptions.

Description

• 

The Import command provides a generic mechanism for importing data in various file formats. The source data can be an external file or URL or a string or ByteArray in the current session.

• 

The form which the imported data takes in Maple is determined by the format (either inferred or specified by the format option) and the output option.

• 

The source option may be set to file or direct. The default, source=file, specifies that the data should be read from the file referenced by origin. In contrast source=direct means that origin is a string or ByteArray which directly contains the data. Note that source=direct requires format to be provided explicitly.

• 

For details on controlling the form of imported data for a particular format, consult the documentation for that format.

Supported Formats

AMF

Base64

BMP

BSON

ByteArray

BYU

CNF

CSV

DGML

DIF

Digraph6

DIMACS

DOT

FASTA

FASTQ

GDF

GenBank

GeoJSON

GEXF

GIF

GPX

Graph6

Graphlet

GraphML

GXL

GZIP

INI

JGF

JPEG

JSON

JVX

KML

KMZ

LEDA

MathML

MAT

MatrixMarket

MLA

MPL

MPS

MW

Newick

OBJ

ODS

OFF

Pajek

PLY

PNG

SHP

Sparse6

STL

SXC

Text

TGF

TIFF

TSPLIB

TSV

UBJSON

VTK

XLS

XLSX

XML

XPORT

YAML

ZIP

ZLIB

Examples

Import comma-separated tabular data as a DataFrame.

Importexample/timedata.csv,base=datadir

Import an image in JPEG format from a remote URL.

urlhttp://www.maplesoft.com/data/examples/jpg/fingerprint.jpg

urlhttp://www.maplesoft.com/data/examples/jpg/fingerprint.jpg

(7.1)

imageImporturl

ImageTools:-Embedimage

Import a cogged gear encoded in Stanford Polygon (PLY) format.

Importexample/gear.ply,base=datadir

Import structured data encoded in the JSON format.

Importexample/address.json,base=datadir

tablephoneNumbers=tablenumber=+1 (519) 747-2373,type=local,tablenumber=+1 (800) 267-6583,type=tollfree,tablenumber=+1 (519) 747-5284,type=fax,founded=1988,address=tablecity=Waterloo,province=ON,postalCode=N2V 1K8,country=Canada,streetAddress=615 Kumpf Drive,companyName=Maplesoft

(7.2)

Import map data from a KMZ file and present it as a 2-D plot.

Importexample/EuropeMap.kmz,base=datadir,plotoptions=view=13..12,46..64,title=Northwest Europe,titlefont=Times,Bold,20

Import data directly from an input string while specifying the CSV format.

CityDataCity,Population\nBeijing,21500000\nMumbai,12478447\nNew York,8405837\n:

ImportCityData,source=direct,format=CSV

(7.3)

Compatibility

• 

The Import command was updated in Maple 2016. By default, Import returns a DataFrame object when importing from the following rectangular formats: CSV, DIF, TSV, XLS, and XLSX. Additionally Import returns a DataSeries object by default when importing from the ODS or SXC formats. Import also supports two new file formats: CNF and GEXF.

• 

The Import command was introduced in Maple 2015.

• 

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

• 

The Import command was updated in Maple 2017.

• 

The base option was introduced in Maple 2017.

• 

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

• 

The labeltype option was introduced in Maple 2023.

• 

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

See Also

convert

Export

Formats

Formats,All

ImportData

ImportMatrix

plottools[importplot]