Skip to main content

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.

Download files

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

Source Distribution

spliterator-0.0.1.tar.gz (2.1 kB view details)

Uploaded Source

File details

Details for the file spliterator-0.0.1.tar.gz.

File metadata

  • Download URL: spliterator-0.0.1.tar.gz
  • Upload date:
  • Size: 2.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for spliterator-0.0.1.tar.gz
Algorithm Hash digest
SHA256 7a0ea862866fd04e9602118e0c6f2582f4cf403c575a09c0fd279ea86ae95b2b
MD5 0856affe71c81d159b9fa5f2658bc21b
BLAKE2b-256 b529c6d3a97ad2f9b2a45d12a324c67ef915b99651b8bf79a92b1bccdd13066f

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.0.1 This release

1 file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page