Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Streaming pull parsing #21

Open
kislyuk opened this issue Feb 16, 2018 · 1 comment
Open

Streaming pull parsing #21

kislyuk opened this issue Feb 16, 2018 · 1 comment

Comments

@kislyuk
Copy link
Owner

kislyuk commented Feb 16, 2018

from xml.etree import ElementTree as ET
parser = ET.XMLPullParser()

with open(input_filename) as fh:
    i = 0
    while True:
        i += 1
        parser.feed(fh.read(1024*1024))
        for event, element in parser.read_events():
            element.clear()
            del element
        if i % 10 == 0:
            print(i)
@kislyuk
Copy link
Owner Author

kislyuk commented Feb 16, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant