| [ Web Proxy ] |
| Viewing: https://arrow.apache.org/docs/python/generated/pyarrow.output_stream.html | [Back] [Original] |
Section Navigation
Create an Arrow output stream.
str, Path, buffer, file-like objectThe source to open for writing.
str optional, default detectThe compression algorithm to use for on-the-fly compression. If detect and source is a file path, then compression will be chosen based on the file extension. If None, no compression will be applied. Otherwise, a well-known algorithm name must be supplied (e.g. gzip).
int, default NoneIf None or 0, no buffering will happen. Otherwise the size of the temporary write buffer.
Examples
Create a writable NativeFile from a pyarrow Buffer:
>>> import pyarrow as pa
>>> data = b"buffer data"
>>> empty_obj = bytearray(11)
>>> buf = pa.py_buffer(empty_obj)
>>> with pa.output_stream(buf) as stream:
... stream.write(data)
...
11
>>> with pa.input_stream(buf) as stream:
... stream.read(6)
...
b'buffer'
or from a memoryview object:
>>> buf = memoryview(empty_obj)
>>> with pa.output_stream(buf) as stream:
... stream.write(data)
...
11
>>> with pa.input_stream(buf) as stream:
... stream.read()
...
b'buffer data'
Create a writable NativeFile from a string or file path:
>>> with pa.output_stream('example_second.txt') as stream:
... stream.write(b'Write some data')
...
15
>>> with pa.input_stream('example_second.txt') as stream:
... stream.read()
...
b'Write some data'
Copyright 2016-2026 Apache Software Foundation.
Apache Arrow, Arrow, Apache, the Apache logo, and the Apache Arrow project logo are either registered trademarks or trademarks of The Apache Software Foundation in the United States and other countries.
Created using Sphinx 9.1.0.
Built with the PyData Sphinx Theme 0.20.0.
| Web Proxy Viewer | New URL | Original Page |