Skip to content

Commit eaf7c0b

Browse files
author
Michael Skelton
committed
Fixed dictionary sorting issue and resolved double parsing
1 parent b0cdb15 commit eaf7c0b

File tree

2 files changed

+14
-17
lines changed

2 files changed

+14
-17
lines changed

RansomwareOverview.xlsx

0 Bytes
Binary file not shown.

UpdateJsonDataset/excel_to_json.py

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22
import xlrd
33
from collections import OrderedDict
44

5-
def formatJson(input):
6-
return json.dumps(json.loads(input), indent=4)
7-
85
def excel_to_json(filename):
96
wb = xlrd.open_workbook(filename)
107
sh = wb.sheet_by_index(0)
@@ -14,21 +11,21 @@ def excel_to_json(filename):
1411

1512
# Iterate through each row in worksheet and fetch values into dict
1613
for rownum in range(1, sh.nrows):
17-
cars = OrderedDict()
14+
wares = OrderedDict()
1815
row_values = sh.row_values(rownum)
19-
cars['Name'] = row_values[0]
20-
cars['Extensions'] = row_values[1]
21-
cars['Patterns'] = row_values[2]
22-
cars['RansomNoteFilenames'] = row_values[3]
23-
cars['Comment'] = row_values[4]
24-
cars['EncryptionAlgorithm'] = row_values[5]
25-
cars['AlternateNames'] = row_values[6]
26-
cars['Decryptor'] = row_values[7]
27-
cars['AdditionalInfo1'] = row_values[8]
28-
cars['AdditionalInfo2'] = row_values[9]
29-
cars['Screenshots'] = row_values[10]
16+
wares['Name'] = row_values[0]
17+
wares['AlternateNames'] = row_values[6]
18+
wares['Extensions'] = row_values[1]
19+
wares['Patterns'] = row_values[2]
20+
wares['RansomNoteFilenames'] = row_values[3]
21+
wares['Comment'] = row_values[4]
22+
wares['EncryptionAlgorithm'] = row_values[5]
23+
wares['Decryptor'] = row_values[7]
24+
wares['AdditionalInfo1'] = row_values[8]
25+
wares['AdditionalInfo2'] = row_values[9]
26+
wares['Screenshots'] = row_values[10]
3027

31-
c_list.append(cars)
28+
c_list.append(wares)
3229

3330
# Serialize the list of dicts to JSON
34-
return formatJson(json.dumps(c_list))
31+
return json.dumps(c_list, indent=4)

0 commit comments

Comments
 (0)