read from a compressed file - Maple Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Programming : Input and Output : File Manipulation : FileTools : FileTools/Compressed/Read

FileTools[Compressed][Read] - read from a compressed file

Calling Sequence

Read(file, type, number)

Parameters

file

-

string or integer file descriptor

type

-

string or a hardware number type to read

number

-

number of characters or numbers to read

Description

• 

The Read command reads a fixed amount of data from a file that has been opened with FileTools[Compressed][Open].

Examples

file := FileTools[TemporaryFilename](cat(FileTools[TemporaryDirectory](),kernelopts(dirsep),"GZtest-"));

file:=/mnt/tmpfs/mpldoc_slot1/mpldoc1/GZtest-h9gGbgMG

(1)

data := LinearAlgebra[RandomVector](100, datatype=float[8]);

data:= 1 .. 100 VectorcolumnData Type: float8Storage: rectangularOrder: Fortran_order

(2)

FileTools[Compressed][WriteFile](file, data);

800

(3)

fd := FileTools[Compressed][Open](file);

fd:=26252400

(4)

FileTools[Compressed][Read](fd, float[8], 1)[1];

4.

(5)

FileTools[Compressed][Read](file, float[8], 99);

1 .. 99 ArrayData Type: float8Storage: rectangularOrder: Fortran_order

(6)

FileTools[Compressed][Close](fd);

0

(7)

FileTools[Remove](file);

zipfile := FileTools[TemporaryFilename](cat(FileTools[TemporaryDirectory](),kernelopts(dirsep),"GZtest-"),".zip");

zipfile:=/mnt/tmpfs/mpldoc_slot1/mpldoc1/GZtest-ZdOP0zdB.zip

(8)

FileTools[Compressed][WriteFile]("sample" in zipfile, "A sample message");

16

(9)

fd := FileTools[Compressed][Open]("sample" in zipfile,'mode'=READ);

fd:=1

(10)

FileTools[Compressed][Read](fd, string, 8);

A sample

(11)

FileTools[Compressed][Read](fd, string, 8);

message

(12)

FileTools[Compressed][Close](fd);

0

(13)

FileTools[Remove](zipfile);

See Also

FileTools[Compressed], FileTools[Compressed][Close], FileTools[Compressed][Open], FileTools[Compressed][Write], FileTools[Compressed][WriteFile], FileTools[Remove]


Download Help Document

Was this information helpful?



Please add your Comment (Optional)
E-mail Address (Optional)
What is ? This question helps us to combat spam