-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathremove_duplicate_keys.py
More file actions
39 lines (34 loc) · 1.52 KB
/
remove_duplicate_keys.py
File metadata and controls
39 lines (34 loc) · 1.52 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
import csv
import helper.Logger as Logger
import helper.Config as Config
from helper.FileHelper import FileHelper, FileExtention
if __name__ == "__main__":
Logger = Logger.Logger()
ReadConfig = Config.ReadConfig()
for platform in ReadConfig.platforms:
# check if the OS_techniques.csv file exists
lower_platform = platform.lower()
if not lower_platform in ReadConfig.dict_platform_mapping:
continue
fileName = f'os_techniques/{ReadConfig.dict_platform_mapping[lower_platform]}_techniques.csv'
if FileHelper.isValidFile(fileName, FileExtention.CSV):
#read the Os_techniques.csv file
list_keywords = []
with open(fileName, 'r') as file:
reader = csv.reader(file)
for row in reader:
try:
list_keywords.append([row[0], row[1]])
except:
Logger.error(f'invalid row found <{row}>, coneinue...')
continue
list_keywords.pop(0) # drop the header
with open(fileName, 'w') as file:
writer = csv.writer(file, delimiter=',', dialect='excel')
writer.writerow(['TID', 'Description of the technique' , 'Ignore'])
written_keys = []
for obj in list_keywords:
if obj[0] in written_keys:
continue
writer.writerow(obj)
written_keys.append(obj[0])