Bases: NativeFile
A stream backed by a regular file descriptor.
Examples
Create a new file to write to:
>>> import pyarrow as pa >>> with pa.OSFile('example_osfile.arrow', mode='w') as f: ... f.writable() ... f.write(b'OSFile') ... f.seekable() ... True 6 False
Open the file to read:
>>> with pa.OSFile('example_osfile.arrow', mode='r') as f: ... f.mode ... f.read() ... 'rb' b'OSFile'
Open the file to append:
>>> with pa.OSFile('example_osfile.arrow', mode='ab') as f: ... f.mode ... f.write(b' is super!') ... 'ab' 10 >>> with pa.OSFile('example_osfile.arrow') as f: ... f.read() ... b'OSFile is super!'
Inspect created OSFile:
>>> pa.OSFile('example_osfile.arrow') <pyarrow.OSFile closed=False own_file=False is_seekable=True is_writable=False is_readable=True>
Methods
Attributes
Read this file completely to a local path or destination stream.
This method first seeks to the beginning of the file.
str
or file-like object
If a string, a local file path to write to; otherwise, should be a writable stream.
int
, optional
The buffer size to use for data transfers.
Flush the stream, if applicable.
An error is raised if stream is not writable.
Return an input stream that reads a file segment independent of the state of the file.
Allows reading portions of a random access file as an input stream without interfering with each other.
int
int
NativeFile
Return file metadata
The file mode. Currently instances of NativeFile may support:
rb: binary read
wb: binary write
rb+: binary read and write
ab: binary append
Read and return up to n bytes.
If nbytes is None, then the entire remaining file contents are read.
int
, default None
bytes
Read and return up to n bytes.
Unlike read(), if nbytes is None then a chunk is read, not the entire file.
int
, default None
The maximum number of bytes to read.
bytes
Read indicated number of bytes at offset from the file
int
int
bytes
Read from buffer.
int
, optional
maximum number of bytes read
Read into the supplied buffer
A writable buffer object (such as a bytearray).
int
number of bytes written
NOT IMPLEMENTED. Read and return a line of bytes from the file.
If size is specified, read at most size bytes.
Line terminator is always bânâ.
int
maximum number of bytes read
NOT IMPLEMENTED. Read lines of the file
int
maximum number of bytes read until we stop
Change current file stream position
int
Byte offset, interpreted relative to value of whence argument
int
, default 0
Point of reference for seek offset
int
The new absolute stream position.
Notes
Values of whence: * 0 â start of stream (the default); offset should be zero or positive * 1 â current stream position; offset may be negative * 2 â end of stream; offset is usually negative
Return file size
Return current stream position
NOT IMPLEMENTED
Write from a source stream to this file.
Source stream to pipe to this file.
int
, optional
The buffer size to use for data transfers.
Write data to the file.
exporter
of buffer protocol
int
nbytes: number of bytes written
Write lines to the file.
Iterable of bytes-like objects or exporters of buffer protocol
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