pyarrow.input_stream#

pyarrow.input_stream(source,compression='detect',buffer_size=None)#

Create an Arrow input stream.

Parameters:
sourcestr,Path, buffer, or file-like object

The source to open for reading.

compressionstr optional, default ‘detect’

The compression algorithm to use for on-the-fly decompression.If “detect” and source is a file path, then compression will bechosen based on the file extension.If None, no compression will be applied.Otherwise, a well-known algorithm name must be supplied (e.g. “gzip”).

buffer_sizeint, defaultNone

If None or 0, no buffering will happen. Otherwise the size of thetemporary read buffer.

Examples

Create a readable BufferReader (NativeFile) from a Buffer or a memoryview object:

>>>importpyarrowaspa>>>buf=memoryview(b"some data")>>>withpa.input_stream(buf)asstream:...stream.read(4)...b'some'

Create a readable OSFile (NativeFile) from a string or file path:

>>>importgzip>>>withgzip.open('example.gz','wb')asf:...f.write(b'some data')...9>>>withpa.input_stream('example.gz')asstream:...stream.read()...b'some data'

Create a readable PythonFile (NativeFile) from a a Python file object:

>>>withopen('example.txt',mode='w')asf:...f.write('some text')...9>>>withpa.input_stream('example.txt')asstream:...stream.read(6)...b'some t'