commit a729770d7902d267b5994e4d5750ed5f9b3a9286 Author: aboelhamd Date: Sun Jun 2 20:41:25 2019 +0200 Script to remove special characters without segmenting diff --git a/rem-spc-chars.py b/rem-spc-chars.py new file mode 100644 index 0000000..f2bfa29 --- /dev/null +++ b/rem-spc-chars.py @@ -0,0 +1,16 @@ +import re +import sys + +if (len(sys.argv) != 3) : + print('\nUsage: python rem-spc-chars.py oldFile newFile'); + sys.exit() + +oldfile = open(sys.argv[1], 'r') +newfile = open(sys.argv[2], 'w+') + +for line in oldfile : + line = re.sub('[\\\(\)\[\]\{\}\<\>\|\$\/\'\"]', '', line) + newfile.write("%s" % line) + +oldfile.close() +newfile.close() diff --git a/spcCharsRem.rb b/spcCharsRem.rb deleted file mode 100644 index a275daa..0000000 --- a/spcCharsRem.rb +++ /dev/null @@ -1,18 +0,0 @@ -if (ARGV.length < 2) - puts "\nUsage : ruby2.3 spcCharsRem.rb oldFilePath newFilePath" - exit -end - -file = File.open(ARGV[1], "w") - -File.open(ARGV[0]).each do |line1| - #line1.delete! ('\\\(\)\[\]\{\}\<\>\|\$\/\'\"') - if ((line1 =~ /\s*\n/) == 0) - next - end - - file.puts line1 -end - -file.close -