Open Chinese Convert  0.4.3
A project for conversion between Traditional and Simplified Chinese
 All Data Structures Files Functions Variables Groups Pages
merge.py
1 #!/usr/bin/env python
2 #coding: utf-8
3 import sys
4 from common import sort_items
5 
6 if len(sys.argv) < 4:
7  print "Merge and sort all text dictionaries"
8  print "Usage: ", sys.argv[0], "[input1] [input2] … [inputN] [output]"
9  exit(1)
10 
11 all_lines = []
12 for i in range(1, len(sys.argv) - 1):
13  input_file = open(sys.argv[i], "r")
14  for line in input_file:
15  all_lines += line
16  input_file.close()
17  all_lines += '\n'
18 
19 output_filename = sys.argv[-1]
20 output_file = open(output_filename, "w")
21 for line in all_lines:
22  output_file.write(line)
23 output_file.close()
24 
25 sort_items(output_filename, output_filename)