read an entire compressed file
ReadFile(filename, outputtype, opts)
string or string:string
(optional) either string, ByteArray, or 'Array'(m,n,hwdatatype)
(optional) options as specified below
format : bzip2, zip, or gzip ; specify the input format explicitly
ReadFile is an all-in-one command to open a file, read and decompress its data, and close the file.
If the given file is in zip format, and an in-zip name is not specified (using inzipname in zipfilename), then the first member of the zip archive is read.
If the second parameter, outputtype, is string then the contents of the file are returned as a string.
If the outputtype is not specified and the in-zip file name ends in ".m", then the contents of the zip file will be parsed as if they were in Maple's internal object format.
If the outputtype is not specified and the in-zip file name ends in ".mpl", then the contents of the zip file will be parsed as if they were a single Maple-syntax text command.
If outputtype is Array, then m and n are integers specifying the dimensions of the Array. The dimensions are optional, and one or more can be set. The hwdatatype indicates one of the integer, float, or complex datatype variations accepted by the 'datatype' option of the Array command.
If outputtype is set to bytes or does not match any of the above criteria then an Array of datatype integer is returned.
Read from a file in gzip format.
file ≔ FileToolsTemporaryFilename⁡FileToolsJoinPath⁡FileToolsTemporaryDirectory⁡,GZtest-
FileToolsCompressedWriteFile⁡file,This is a test
This is a test
Read from a file in zip format.
zipfile ≔ FileToolsTemporaryFilename⁡cat⁡FileToolsTemporaryDirectory⁡,kernelopts⁡dirsep,GZtest-,.zip
FileTools[Compressed][WriteFile]("first" in zipfile, "one");
FileTools[Compressed][WriteFile]("second" in zipfile, Array(1..50, 0, datatype=integer));
FileTools[Compressed][ReadFile]("second" in zipfile);
The FileTools[Compressed][ReadFile] command was introduced in Maple 16.
For more information on Maple 16 changes, see Updates in Maple 16.
Download Help Document
What kind of issue would you like to report? (Optional)