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.2.0.tar.gz
(4.0 kB
view hashes)
Built Distribution
Close
Hashes for streamcat-0.2.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ff1751100eb5eaee114fc6045bab86a933bf61d711a59868847cd6ba7a8f4344 |
|
MD5 | 88ddbd3599934ae9e5ff989d81146644 |
|
BLAKE2b-256 | b1245b4bc811ab8ba345822408b3ad4af0d8c062de4cf74e0a3fca198b98cbf4 |