forked from TryCatchHCF/Cloakify
-
Notifications
You must be signed in to change notification settings - Fork 0
/
removeNoise.py
38 lines (33 loc) · 849 Bytes
/
removeNoise.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
#!/usr/bin/python
#
# Filename: removeNoise.py
#
# Version: 1.0.0
#
# Author: Joe Gervais (TryCatchHCF)
#
# Summary: Removes random noise that has been prepended to a cloaked file
# (see cloakify.py).
#
# Description:
# Read in the noise-enhanced cloaked file and reprint each line without the
# prepended noise.
#
# Example:
#
# $ ./removeNoise.py 2 noisyCloaked.txt cloaked.txt
import os, sys, getopt
if ( len(sys.argv) != 4 ):
print "usage: removeNoise.py <numberOfColumnsToStrip> <noisyFilename> <outputFile>"
print
exit
else:
numberOfColumnsToStrip = int( sys.argv[1] )
with open( sys.argv[2] ) as file:
noisyFile = file.readlines()
file.close()
with open( sys.argv[3], "w" ) as file:
for line in noisyFile:
if line != '\n':
file.write( ' '.join(line.split(' ')[numberOfColumnsToStrip:]))
file.close()