fixed rewrite and stuff

This commit is contained in:
Michael Scalzetti 2022-10-26 20:40:01 -04:00
parent d4f5fe70da
commit da15e54a64

View File

@ -55,28 +55,6 @@ class Sniffer:
file_data.append(item)
return file_data
def parse_into_dicts_safe(self, csv_data):
template = []
sniff_data = []
for line_index in range(len(csv_data)):
line = csv_data[line_index]
if line_index == 0:
continue
if line_index == 1:
for item in line:
template.append(item)
continue
temp = {}
if line == []:
break
for item_index in range(len(line)):
temp[template[item_index]] = line[item_index]
sniff_data.append(temp)
return sniff_data
def parse_into_dicts(self, csv_data):
template = []
sniff_data = []
@ -89,26 +67,27 @@ class Sniffer:
if not sniff_data == []:
sniff_data_parts.append(sniff_data)
sniff_data = []
continue
if make_template:
template = []
for item in line:
template.append(item)
template.append(item.strip())
make_template = False
continue
temp = {}
for item_index in range(len(line)):
try:
temp[template[item_index]] = line[item_index]
except:
pass
sniff_data.append(temp)
return sniff_data_parts
def parse_sniff(self, full_filepath):
file_data = self.parse_csv()
sniff_data = self.pars_into_dicts(file_data)
for packet in sniff_data[1]:
print(packet)
file_data = self.parse_csv(full_filepath)
sniff_data = self.parse_into_dicts(file_data)
return sniff_data