Last active
February 19, 2016 04:58
-
-
Save rmuslimov/5e4a7fbc2bd892b3f104 to your computer and use it in GitHub Desktop.
Python version of parsing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
from datetime import datetime | |
from lxml import etree | |
def import_file(filename): | |
with open(filename) as f: | |
body = etree.fromstring(f.read()) | |
return etree.ETXPath( | |
'.//{http://schemas.xmlsoap.org/soap/envelope/}Body')(body) | |
def walk(path): | |
return [ | |
import_file(os.path.join(path, each)) for each | |
in os.listdir(path) | |
] | |
def main(): | |
t = datetime.now() | |
print len(walk('/Users/rmuslimov/projects/logs/d=12')) | |
print datetime.now() - t | |
main() | |
# Time elapsed: 0:00:00.379423 sec |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment