-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmerge_feature_file.py
66 lines (52 loc) · 1.26 KB
/
merge_feature_file.py
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
'''
file join
usage: python merge_features.py directory output_file
'''
import sys
import os
def usage_str():
'''
usage string
'''
print("usage: python merge_features.py <directory> <output_file>")
def decorator(n):
'''
'''
print("*"*n)
def join_files(directory, output_file):
'''
join all input_files into one output_file
'''
# Files in directory
print("files in the directory:")
input_files = []
for file in os.listdir(directory):
file = directory + "/" + file
print(file)
input_files.append(file)
print("\nwriting to :"+output_file)
output_file = open(output_file, "w")
write_header = False
for file in input_files:
file = open(file)
header = file.readline()
data = file.readlines()
# write header once
if not write_header:
output_file.write(header)
write_header = True
for line in data:
output_file.write(line)
file.close()
# close output file
output_file.flush()
output_file.close()
# **** Starts here ****
decorator(25)
# read file and p from args
if(len(sys.argv) < 3):
usage_str()
else:
join_files(sys.argv[1], sys.argv[2])
print("DONE")
decorator(25)