forked from enormandeau/Scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathline_remove.py
More file actions
executable file
·34 lines (26 loc) · 795 Bytes
/
line_remove.py
File metadata and controls
executable file
·34 lines (26 loc) · 795 Bytes
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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Remove lines starting with elements contained in a 'remove' file.
Remove file contains one name per line.
Usage:
%program <input_file> <remove_file> <output_file>"""
import sys
try:
in_file = open(sys.argv[1]) # Input file
remove_file = sys.argv[2] # Input remove file, one name per line
out_file = sys.argv[3] # Output file
except:
print __doc__
sys.exit(0)
remove = set()
with open(remove_file) as f:
for line in f:
line = line.strip()
if line != "":
remove.add(line)
lines = [l.strip() for l in in_file.readlines()]
with open(out_file, "w") as f:
for line in lines:
name = line.split("\t")[0]
if name not in remove:
f.write(line + "\n")