-
Notifications
You must be signed in to change notification settings - Fork 1
/
listMakers.py
131 lines (87 loc) · 3.33 KB
/
listMakers.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
import os
import csv
import pathlib
import glob
def search_files(folder_path):
matching_files = []
# Walk through the directory
for root, dirs, files in os.walk(folder_path):
print(files)
for file in files:
# Check if the file ends with '.bdf' and contains 'npu'
if file.endswith('.bdf') and 'npu' in file.lower():
# Add the full path of the file to the list
matching_files.append(os.path.join(root, file))
return matching_files
def search_files_lst(folder_path):
matching_files1 = []
# Walk through the directory
for root, dirs, files in os.walk(folder_path):
print(files)
for file in files:
# Check if the file ends with '.bdf' and contains 'lst'
if file.endswith('.bdf') and 'lst' in file.lower():
# Add the full path of the file to the list
matching_files1.append(os.path.join(root, file))
return matching_files1
def search_files_ern(folder_path):
matching_files2 = []
# Walk through the directory
for root, dirs, files in os.walk(folder_path):
print(files)
for file in files:
# Check if the file ends with '.bdf' and contains 'ern'
if file.endswith('.bdf') and 'ern' in file.lower():
# Add the full path of the file to the list
matching_files2.append(os.path.join(root, file))
return matching_files2
def list_files(directory):
for file in pathlib.Path(directory).rglob("*"):
print(file)
def list_files2(directory):
for file in glob.glob(directory + '/**/*', recursive=True):
print(file)
# Example usage:
def list_files3(directory):
for root, dirs, files in os.walk(directory):
for file in files:
print(os.path.join(root, file))
# Specify the folder path you want to search
folder_to_search = 'C:/Users/John/MATLAB/Documents/MATLAB/soarCinci/.'
# Call the function and get the list of matching files
result = search_files(folder_to_search)
resultLst = search_files_lst(folder_to_search)
resultErn = search_files_ern(folder_to_search)
# Print the list of matching files
print(result)
print(resultLst)
print(resultErn)
saa=os.listdir()
#print(saa)
# Example usage:
#list_files(folder_to_search)
#list_files2(folder_to_search)
# Example usage:
#list_files3(folder_to_search)
#list_files3(folder_to_search)
#print(xx)
with open("outputCinci.csv", "w", newline='') as csvfile:
# Create a CSV writer object
writer = csv.writer(csvfile)
# Write the fieldnames (column headers)
writer.writerow(saa)
with open("outputNpu.csv", "w", newline='') as csvfile:
# Create a CSV writer object
writer = csv.writer(csvfile)
# Write the fieldnames (column headers)
writer.writerow(result)
with open("outputLst.csv", "w", newline='') as csvfile:
# Create a CSV writer object
writer = csv.writer(csvfile)
# Write the fieldnames (column headers)
writer.writerow(resultLst)
with open("outputErn.csv", "w", newline='') as csvfile:
# Create a CSV writer object
writer = csv.writer(csvfile)
# Write the fieldnames (column headers)
writer.writerow(resultErn)