Skip to main content
Join the official 2019 Python Developers SurveyStart the survey!

Split line streams into managable chunks

Project description

spliterator

Split line streams into managable chunks

Usage

Take things.txt as follows.

Thing Name Thing 1
Thing Color Red
Thing Hair Big
Thing Motto I am Number 1!
Thing Name Thing 2
Thing Color Red
Thing Hair Big
Thing Motto Seconds Please!

And lets iterate through each line while adding in start and end events around each individual thing.

>>> import spliterator
>>> for event, line in spliterator.chunk(open('things.txt'), 'Thing Name'):
...   print(event, line)
...
START None
LINE Thing Name Thing 1
LINE Thing Color Red
LINE Thing Hair Big
LINE Thing Motto I am Number 1!
END None
START None
LINE Thing Name Thing 2
LINE Thing Color Red
LINE Thing Hair Big
LINE Thing Motto Seconds Please!
END None

Now we can process specific things properly based on the event variable.

Project details


Release history Release notifications

Download files

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

Files for spliterator, version 0.0.1
Filename, size File type Python version Upload date Hashes
Filename, size spliterator-0.0.1.tar.gz (2.1 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page