-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlast_index_remover.py
50 lines (39 loc) · 1 KB
/
last_index_remover.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
import os
import sys
import fileinput
import argparse
# print ("Text to search for:")
# textToSearch = input( "> " )
# print ("Text to replace it with:")
# textToReplace = input( "> " )
ap=argparse.ArgumentParser()
ap.add_argument('-i','--folder',type=str,default='',
help="path")
args=vars(ap.parse_args())
img_path=args["folder"]
imgs_path=os.listdir(img_path)
# for images in imgs_path:
# print ("File to perform Search-Replace on:")
fileToSearch = imgs_path
for text_file in fileToSearch:
print(str(text_file))
text_file1 =os.path.join(img_path, text_file)
tempFile = open( text_file1, 'r+' )
for line in fileinput.input(text_file1):
# try:
line1 = line
change = line.split(",")
# print(change)
change = change[:8]
change[7] = "0"
# baby = String.Join(",", change)
baby = ",".join(change)
print(baby)
# change = "0"
# print(change)
# print(str(change))
tempFile.write(line.replace(line1, baby))
# except:
# continue
tempFile.close()
# input( '\n\n Press Enter to exit...' )