Spaces:
Sleeping
Sleeping
Samarth Naik commited on
Commit ·
1c9f2d5
1
Parent(s): 81fff55
added jsonshift.py
Browse files- jsonshift.py +18 -0
jsonshift.py
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import csv
|
| 2 |
+
import json
|
| 3 |
+
with open('network_logs.csv', 'r') as f:
|
| 4 |
+
reader = csv.DictReader(f)
|
| 5 |
+
data = []
|
| 6 |
+
for row in reader:
|
| 7 |
+
row['src_port'] = int(row['src_port'])
|
| 8 |
+
row['dst_port'] = int(row['dst_port'])
|
| 9 |
+
row['packet_size'] = int(row['packet_size'])
|
| 10 |
+
row['tcp_flags'] = int(row['tcp_flags'])
|
| 11 |
+
row['seq'] = int(row['seq'])
|
| 12 |
+
row['ack'] = int(row['ack'])
|
| 13 |
+
row['window'] = int(row['window'])
|
| 14 |
+
data.append(row)
|
| 15 |
+
|
| 16 |
+
payload = {'model_type': 'lightGBM', 'file': data}
|
| 17 |
+
with open('payload.json', 'w') as f:
|
| 18 |
+
json.dump(payload, f)
|