import sys import time from backup_monitoring.parsing.parsers import vmquery as parser file = open('test.txt', 'r') stream = parser.stream(file) i = 0 for record in stream: i += 1 print i #print record try: instance = parser.parse(record) #for key, value in instance.items(): # print '[%s] = [%s]' % (key, value) except: for line in record: print line sys.exit(1) # time.sleep(5) file.close()