Use generator in streaming mode
See original GitHub issueCallbacks are not very convenient way to handle streaming. For example:
def handle_artist(_, artist):
print(artist['name'])
return True
xmltodict.parse(GzipFile('discogs_artists.xml.gz'),
item_depth=2, item_callback=handle_artist)
Could look like this:
data = GzipFile('discogs_artists.xml.gz')
for _, artist in xmltodict.parse(data, item_depth=2):
print(artist['name'])
This looks much more pythonic.
Issue Analytics
- State:
- Created 8 years ago
- Reactions:11
- Comments:18 (9 by maintainers)
Top Results From Across the Web
Node.js Generators for Streaming - derp turkey
This article will discuss how you can use a Generator to efficiently stream data to a consumer. Generators are a mechanism for creating...
Read more >Streaming Response — TurboGears 2.4.3 documentation
Streaming involves returning a generator from your controller, this will let the generator create the content while being read by client.
Read more >Comparing the Stream API and (async) generators in Node.js ...
In this post, we will implement four infinite counters and see how streams and generators behave similarly but are fundamentally different.
Read more >Essentia streaming mode architecture
Open-source library and tools for audio and music analysis, description and synthesis.
Read more >Stream transformer from async generator and options
Note that using .from() does not change that the stream's source is an (async) generator, and generators process one chunk of data at...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I ended up using the standard XML lib to yield dictionaries. Not in progress on my end. That original PR looked good though if you want to harvest its generator.
Sent from my iPhone
it looks like #104 had generator stuff and it hasn’t been touched since May? If I pulled that out and made it a standalone PR would you accept it @martinblech ?