Import - Maple Programming Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Programming : Input and Output : Import

Import

import external data into Maple

 

Calling Sequence

Parameters

Options

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.

• 

output : symbol

  

This option specifies the desired method for representing the imported data. For possible values consult the documentation for a specific format.

• 

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.

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

BMP

BYU

CNF

CSV

DGML

DIF

Digraph6

DIMACS

DOT

FASTA

FASTQ

GenBank

GEXF

GIF

GPX

Graph6

Graphlet

GraphML

GXL

GZIP

INI

JGF

JPEG

JSON

JVX

KML

KMZ

LEDA

MathML

MAT

MatrixMarket

MLA

MPL

MPS

MW

OBJ

ODS

OFF

Pajek

PLY

PNG

SHP

Sparse6

STL

SXC

Text

TGF

TIFF

TSPLIB

TSV

Text

VTK

XLS

XLSX

XML

XPORT

YAML

ZIP

ZLIB

 

 

 

 

Examples

Import comma-separated tabular data as a DataFrame.

Importexample/timedata.csv,base=datadir

1234561Mar 06 01:16 3/7/200526.860912411.4143014721071.5058944021070.06482Mar 06 20:12 3/7/200525.756241812.3582296951072.4976144071070.05913Mar 06 20:43 3/7/200525.127064283.0292123161073.3144771841070.09424Mar 07 00:25 3/7/200525.122490952.4968554191072.6560199931070.06375Mar 07 00:44 3/7/200522.759192762.7224987521072.8185900041070.03536Mar 07 00:59 3/7/200522.206311129.8590108321071.0299759981070.04477Mar 08 00:15 3/8/200522.114772988.3336403211078.5792302261070.02958Mar 08 00:16 3/8/200521.412271131.1742728591071.2179988061070.03729Mar 08 00:16 3/8/200521.332533154.9503505491065.2390080091070.058310Mar 08 00:16 3/8/200520.627523091.7655082081071.8700920031070.0592`:``:``:``:``:``:`28 x 6 DataFrame

(6.1)

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

(6.2)

imageImporturl

image0.1882352941176470.5686274509803920.5058823529411760.4705882352941180.4941176470588240.5058823529411760.4862745098039220.5098039215686270.5019607843137250.501960784313725...0.5411764705882350.9843137254901960.9921568627450980.9921568627450981.1.0.9921568627450981.1.1....0.4784313725490200.9607843137254901.1.1.0.9843137254901960.9647058823529410.9960784313725490.9960784313725490.996078431372549...0.5176470588235290.9960784313725491.1.0.9882352941176470.9803921568627450.9725490196078431.1.1....0.5019607843137250.9764705882352941.0.9803921568627450.9882352941176471.1.1.1.1....0.4784313725490200.9607843137254900.9921568627450980.9803921568627451.1.0.9882352941176470.9882352941176470.9960784313725490.996078431372549...0.5019607843137250.9921568627450981.0.9921568627450981.1.0.9803921568627450.9803921568627451.1....0.4941176470588240.9843137254901961.0.9725490196078430.9725490196078431.1.1.0.9921568627450980.992156862745098...0.4980392156862751.0.9921568627450981.1.0.9803921568627450.9960784313725490.9921568627450981.1....0.4941176470588240.9960784313725490.9921568627450981.1.0.9843137254901960.9960784313725490.9960784313725491.1....`:``:``:``:``:``:``:``:``:``:`240 × 256 Array

(6.3)

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

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

(6.4)

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

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

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

CityDataCity,Population Beijing,21500000 Mumbai,12478447 New York,8405837 :

ImportCityData,source=direct,format=CSV

PopulationBeijing21500000Mumbai12478447New York8405837

(6.5)

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.

See Also

Export

Formats

Formats,All

ImportData

ImportMatrix

plottools[importplot]