Skip to main content

Streamly is a very simple yet powerful wrapper for streams.

Project description

Streamly is a very simple yet powerful wrapper for streams (file-like objects). It is primarily designed to help with the cleaning up of flat data during on the fly read operations.

A typical use case that is especially prevalent within digital marketing, is wanting to download/upload a web stream to some target location that expects clean, flat delimited data but the stream includes unwanted header and footer data. Developers often deal with this by loading the data as-is into an interim location and then opening the file and culling the unwanted leading and trailing lines. This approach works but limitations include: not easily reproducible; increases the complexity of the solution; assumes a storage component; inefficient with large data sets.

Streamly solves this problem by handling the unwanted headers and footers on the fly in a highly efficient manner.

Documentation: https://streamly.readthedocs.io

Installation

Requires Python 3.1+

With pipenv

Install:

pipenv install streamly

OR Update:

pipenv update streamly

With pip

Install & Update:

pip install streamly --upgrade

Example Usage

The below example writes a byte stream to a file, removing the unwanted header and footer details on the fly.

import io

import streamly


my_stream = io.BytesIO(
b"""Header
Metadata
Unwanted
=
Garabage

Report Fields:
col1,col2,col3,col4,col5
data,that,we,actually,want
and,potentially,loads,of,it,
foo,bar,baz,lorem,ipsum
foo,bar,baz,lorem,ipsum
foo,bar,baz,lorem,ipsum
...,...,...,...,...
Grand Total:,0,0,1000,0
More
Footer
Garbage
"""
)

wrapped_stream = streamly.Streamly(my_stream, header_row_identifier=b"Report Fields:\n",
                                   footer_identifier=b"Grand")

data = wrapped_stream.read(50)
while data:
    print(data)
    data = wrapped_stream.read(50)

Features

Includes the following functionality during on the fly read operations:

  • Adjoining of multiple streams

  • Removal of header and footer data, identified by a value (e.g. byte string or string)

  • Logging of read progress

  • Guaranteed read size (where the data is not yet exhausted)

  • Consistent API for streams returning byte strings or strings

Project details


Release history Release notifications | RSS feed

This version

0.3

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Streamly-0.3.tar.gz (6.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

Streamly-0.3-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

Details for the file Streamly-0.3.tar.gz.

File metadata

  • Download URL: Streamly-0.3.tar.gz
  • Upload date:
  • Size: 6.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for Streamly-0.3.tar.gz
Algorithm Hash digest
SHA256 ddaa8540ae074682b8f60b62b6a9ddf1c7889b10d87c2ad9a629a8527f4a3874
MD5 d3e40c2f2ed2a0e00344ce895ba0e139
BLAKE2b-256 99c49029250e22e70a8c75e253bace1f590e1922549874069645e0abf977b63d

See more details on using hashes here.

File details

Details for the file Streamly-0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for Streamly-0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 88e5614539c82ea3cbfab583910d8c28cbef89557a05073c42147a80ddea3d07
MD5 141d39fd44fd2bd2ee2a9b8f88fe3cd3
BLAKE2b-256 0d6068ab984271e702e78c3f0ec48127be2443191f3e3c84f1b074ee4b27d138

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page