Connectivity
New File Formats
Import and Export
JSON
The new JSON package allows import and export of files and strings in the JSON format, a popular format used by many modern applications for exchanging structured data. Example: Import JSON data encoding the mailing address of Maplesoft headquarters.
currentdirFileTools:-JoinPathexample, base=datadir:
T ≔ JSON:-ParseFileaddress.json
tableaddress=tablestreetAddress=615 Kumpf Drive,city=Waterloo,postalCode=N2V 1K8,country=Canada,province=ON,founded=1988,phoneNumbers=tabletype=local,number=+1 (519) 747-2373,tabletype=tollfree,number=+1 (800) 267-6583,tabletype=fax,number=+1 (519) 747-5284,companyName=Maplesoft
TcompanyName
Maplesoft
Taddresscity, Taddresscountry
Waterloo,Canada
Cartographic Data
The KML file format and the related KMZ compressed format are popular XML-based map data formats which are used by many mapping applications.
KML permits geographic areas and contours to be defined using line and polygon primitives.
The new Import command, described in more detail below, can import a KML map file and represent it as a 2-D plot. In addition to KML and KMZ, Import also supports the GPX and SHP cartographical formats. Example: Import a four-colour KMZ map of the 48 contiguous states of the United States of America.
Importhttp://www.maplesoft.com/data/examples/kmz/CONUS.kmz, title = The Contiguous United States, titlefont = Times, Bold, 20, size = 800, 400
Biological Sequence Formats
The Import and Export commands also support three popular text-based formats for representing DNA and protein sequences: FASTA, FASTQ, and GenBank. You can import genetic or proteinomic data into your session and use text processing tools to analyze the imported sequence.
Example: Import a DNA sequence from a FASTA file.
mtDNASequence≔ImporthumanmtDNA.fasta:
Study the metadata for the first sequence in the file:
mtDNASequence1,1
Human mitochondrial genome,HVR2,CR,HVR1
Examine the nucleotide codes at positions 16200 through 16250:
mtDNASequence1,216200..16250
TTACAAGCAAGTACAGCAATCAACCCTCAACTATCACACATCAACTGCAAC
Count the frequency of each of nucleotide base (A, C, G, or T) in the sequence:
frequencies ≔ StringTools:-CharacterFrequenciesmtDNASequence1,2
A=5118,C=5185,G=2175,N=1,T=4092
Statistics:-ColumnGraph frequencies
Graph Theory Formats
The GraphTheory package now supports six new formats for import and export: DGML , Graphlet , GraphML , GXL , Pajek , and TGF. For more information on supported graph-theoretic formats, see Formats.
GraphML Format
Pajek Format
GraphTheory:-DrawGraphImportpetersen.graphml
GraphTheory:-DrawGraphImportdraco.net,color=red
The new Import and Export commands provide a generic command-based mechanism to move data between Maple and the operating environment.
The Import command provides a ubiquitous mechanism for importing data with a single command.
Import is agnostic of the type of data: it can handle numeric and tabular data, images, cartographic data, specialized text file formats like XML and JSON, and special-purpose formats for graph theory and linear optimization. Several examples appear below.
Import 3D Models
Import Tabular Data
Import Structured Data
Import Graphs
Importdodecahedron.stl
M ≔ Importtimedata.csv
M1..5,1..2
Company ≔Importaddress.json:
CompanycompanyName
Companyfounded
1988
CompanyaddressstreetAddress
615 Kumpf Drive
Companyaddresscity
Waterloo
Companyaddresscountry
Canada
Company ≔Importcoxeter.col;
Graph 1: an undirected unweighted graph with 28 vertices and 42 edge(s)
GraphTheory:-DrawGraph,style=spring
The Export command provides an equally generic and powerful mechanism for exporting data from Maple with a single command.
Export Visualizations
Export to MathML
OutputFile ≔ FileTools:-JoinPathgraphic.png, base=homedir
C:\Users\JohnSmith\graph.png
E:=seq⁡Array⁡evalf⁡seq⁡1+sin⁡10⁢π⁢i15⁢j,i=1..15,j=1..15:
MyGraphic ≔ dataplotE,bar,format=stacked,color=Maroon..RoyalBlue,gridlines
ExportOutputFile, MyGraphic
22685
OutputFile ≔ FileTools:-JoinPathintegral.mml, base=homedir
C:\Users\JohnSmith\integral.mml
Compute an integral in Maple and export it to a MathML file.
MyIntegral ≔ ∫sinx2+x ⅆx
12⁢2⁢π⁢cos⁡14⁢FresnelS⁡2⁢x+12π−sin⁡14⁢FresnelC⁡2⁢x+12π
ExportOutputFile, MyIntegral
3088
Demonstrate that the export was successful by re-importing the data and retrieving the original expression.
ImportOutputFile
Download Help Document