source: make_tictocs.py @ 0:2f43cb89e87c

Revision 0:2f43cb89e87c, 749 bytes checked in by andre.hagenbruch@rub.de, 8 years ago (diff)

Initial commit for version 0.2

Line 
1#!/usr/bin/env python
2# encoding: utf-8
3"""
4make_tictocs.py
5
6Created by Andre Hagenbruch on 2009-11-30.
7Copyright (c) 2009 University Library Bochum. All rights reserved.
8"""
9
10import re
11
12def parse(file):
13        fields_re = re.compile('^(\d+)\s+(.+?)\s+(http.+?)?\s(\d{4}-\w{4})?.*', re.DOTALL)
14       
15        tictocs = {}
16       
17        f = open(file, 'r')
18       
19        for line in f:
20                fields_match = fields_re.search(line)
21                if fields_match.group(3) is not None:
22                        #stmt.execute(id = fields_match.group(1), title = fields_match.group(2), feed = fields_match.group(3), issn = fields_match.group(4))
23                        tictocs.setdefault(fields_match.group(4), fields_match.group(3))
24       
25        print tictocs
26       
27
28def main():
29        parse('/Users/andre/Dev/tictoc/tictoc/data.txt')
30
31
32if __name__ == '__main__':
33        main()
34
Note: See TracBrowser for help on using the repository browser.