File: combineJournalLists.py

package info (click to toggle)
jabref 2.10%2Bds-3
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 13,808 kB
  • ctags: 12,245
  • sloc: java: 90,549; xml: 1,571; python: 270; sh: 207; makefile: 16
file content (31 lines) | stat: -rw-r--r-- 791 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/python

# Python script for combining several journal abbreviation lists
# and producing an alphabetically sorted list. If the same journal
# names are repeated, only the version found last is retained.
#
# Usage: combineJournalLists.py outfile infile1 infile2 ...

import sys
import fnmatch
import os

outFile = sys.argv[1]
dictionary = dict()
for i in range(2,len(sys.argv)):
    count = 0
    f = open(sys.argv[i], "r")
    for line in f:
	if line[0] != "#":
	    count = count+1
	    parts = line.partition("=")
	    dictionary[parts[0].strip()] = line.strip()
    f.close()
    print sys.argv[i]+": "+str(count)

print "Combined key count: "+str(len(dictionary))

f = open(outFile, "w")
for key in sorted(dictionary.iterkeys()):
      f.write(dictionary[key]+"\n")
f.close()