-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathget_data.py
More file actions
48 lines (43 loc) · 1.39 KB
/
get_data.py
File metadata and controls
48 lines (43 loc) · 1.39 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
import re
import os
#fpaths = ['C:\Users\SHARMILLA\PycharmProjects\R_D\recon','C:\Users\SHARMILLA\PycharmProjects\R_D\vision']
prefixes = ('prebill','CEUE')
fpaths = ['recon','vision']
SearchStr = '23456'
import glob
requredFiles = []
for fpath in fpaths:
for r, d, f in os.walk(r'C:\Users\SHARMILLA\PycharmProjects\R_D'):
for newfile in f:
if newfile.startswith(prefixes):
requredFiles.append(os.path.join(r, newfile))
print("hello")
'''
for fpath in fpaths:
arr = os.listdir(fpath)
#arr = os.walk(fpath)
#print(arr)
for eachfile in arr:
if eachfile.startswith(prefixes):
print(1, eachfile, prefixes)
requredFiles.append(os.path.join(fpath, eachfile))
print("hello")
'''
print(requredFiles)
for myfile in requredFiles:
content_written = False
resultfile = SearchStr+'_'+os.path.basename(myfile)
with open(myfile) as infile, open('resultfile', 'w') as outfile:
#print(outfile)
copy = False
for line in infile:
if re.match("#Account:23456(.*)", line):
outfile.write(line)
copy = True
content_written = True
elif re.match("#Account(.*)", line):
copy = False
elif copy:
outfile.write(line)
if not content_written :
os.remove(resultfile)