-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchange_result.py
More file actions
53 lines (36 loc) · 1.14 KB
/
Copy pathchange_result.py
File metadata and controls
53 lines (36 loc) · 1.14 KB
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
import os
import linecache
# f = open('demo.txt')
# f_new = open('new.txt', 'w')
#
# for index in range(len(f.readlines())):
# line = linecache.getline('demo.txt', index+1)
# if line[:5] == '/home':
# path = str(index) + '\n'
# f_new.write(path)
#
# f_org = open('demo.txt')
# f_new = open('new.txt')
# f_final = open('final.txt','w')
# for i in range(len(f_new.readlines())):
# i_data = linecache.getline('new.txt', i+1)
# start = int(linecache.getline('new.txt', i+1).strip()) + int(1)
# end = int(linecache.getline('new.txt', i+2).strip())
# # print 'lalalla', start, end
# for num in range(start, end): #num
# path = linecache.getline('demo.txt', int(i_data) + 1).strip()
# file = path + ',' + linecache.getline('demo.txt', int(num) + 1).strip() +'\n'
# f_final.write(file)
#
f = open('final.txt')
result = open('result5.txt', 'w')
for line in f.readlines():
new = line.replace('JPEGImages', 'labels').replace('jpg', 'txt').replace('wrc','ld')
# new = line.replace('wrc', 'ld')
print new
result.write(new)
# for eachline in f.readlines():
# print eachline
# if eachline[:5] == '/home':
# path = eachline
# print path