method
chararray.
tofile
(fid, sep="", format="%s")¶
Write array to a file as text or binary (default).
Data is always written in âCâ order, independent of the order of a. The data produced by this method can be recovered using the function fromfile().
Parameters:An open file object, or a string containing a filename.
Changed in version 1.17.0: pathlib.Path
objects are now accepted.
Separator between array items for text output. If ââ (empty), a binary file is written, equivalent to file.write(a.tobytes())
.
Format string for text file output. Each entry in the array is formatted to text by first converting it to the closest Python type, and then using âformatâ % item.
Notes
This is a convenience function for quick storage of array data. Information on endianness and precision is lost, so this method is not a good choice for files intended to archive data or transport data between machines with different endianness. Some of these problems can be overcome by outputting the data as text files, at the expense of speed and file size.
When fid is a file object, array contents are directly written to the file, bypassing the file objectâs write
method. As a result, tofile cannot be used with files objects supporting compression (e.g., GzipFile) or file-like objects that do not support fileno()
(e.g., BytesIO).
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4