Encode and decode concatenated objects as streams
Project description
Encoding a JSON iterator into a stream:
def gen_records():
yield b'{"foo": "bar"}'
yield b'{"baz": [1, 2, 3]}'
stream = streamcat.iterator_to_stream(gen_records())
# `stream` can then be used just like any other `io.RawIOBase`
with open('/tmp/jsoncat', 'wb') as destination:
shutil.copyfileobj(stream, destination)
Decoding a stream into a generator:
decoder = json.JSONDecoder()
with open('/tmp/jsoncat', 'rb') as source:
records = streamcat.stream_to_iterator(source, decoder)
for record in records:
print(record)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
streamcat-0.1.1.tar.gz
(3.0 kB
view hashes)
Built Distribution
Close
Hashes for streamcat-0.1.1-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 036b2379013167ad3cf758987624c99c9d77d93d5566a87b493776116fa92c31 |
|
MD5 | 0d1d7a13c557f6da1be402710bddf6ae |
|
BLAKE2b-256 | 8d1951bde40eb4502994a05064174f0fa9d54bac5d7b6dc78a70ac56434b36da |