9f4bd5768a7d3acada20389118b273ab83f7fa96
[qpalma.git] / ParaParser / simple_example.py
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3
4 import sys
5 from ParaParser import *
6
7 def run(file):
8 parser = ParaParser("%d%s%s%d%d",["field0","field1","field2","field3","field4"],5)
9 parser.parseFile(file)
10 entry1_dict = parser.fetchEntry(1111)
11 print entry1_dict
12 entry2_dict = parser.fetchEntry(2222)
13 print entry2_dict
14 entry3_dict = parser.fetchEntry(3333)
15 print entry3_dict
16
17 del parser
18
19 parser2 = ParaParser("%d%s",["field0","field1"],2)
20 file = 'test2.data'
21 parser2.parseFile(file)
22 entry1_dict = parser2.fetchEntry(1111)
23 print entry1_dict
24
25 parser2 = ParaParser("%d%s",["field0","field1"],2)
26 file = 'test2.data'
27 parser2.parseFile(file)
28 entry1_dict = parser2.fetchEntry(1111)
29 print entry1_dict
30
31
32 if __name__ == '__main__':
33 run('test.data')