-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathpcap_to_csv.py
34 lines (21 loc) · 950 Bytes
/
pcap_to_csv.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
import os
from flowmeter import Flowmeter
path = 'pcapF/'
arr = os.listdir(path)
print("\n[* ] - Number of Files to convert = ", len(arr), "\n")
# print(type(arr))
# for uniquely naming the csv files
for file in range(0, len(arr)):
file_name = 1
print("\n[ * ] - Converting data_{}.pcap to data{}.csv\n".format(
file_name, file_name))
cat_pcap = path + arr[file]
print("\n>>> Full path of data_{}.pcap: \n".format(file_name), cat_pcap)
feature_gen = Flowmeter(offline=cat_pcap, outfunc=None,
outfile='csvs/out{}.csv'.format(file_name))
feature_gen.run()
print(
"\n[ * ] - Converted data_{}.pcap to data_{}.csv\n".format(file_name, file_name))
# use norm.py class to perform to apply preprocessing on data here and d
#make code modular, use date time module to figure naming of
#mechanism to clear files so that they're not posessed againa nd again