-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchatParser.py
More file actions
87 lines (62 loc) · 2.33 KB
/
Copy pathchatParser.py
File metadata and controls
87 lines (62 loc) · 2.33 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import pandas as pd
list = []
arr = [[]]
oob = 0
dl = 0
filename = input('Enter the name of the text folder, eg buttonData.txt : ')
with open(filename, 'r') as file_object:
line = file_object.readline()
while line:
if 'OOB: ' in line:
holder = line[27:].strip('\n')
holder = holder.split(',')
data = holder[0].split(':') + holder[1].split(':')
oob_dl = data[1::2]
oob_dl = [element.strip() for element in oob_dl]
oob = oob_dl[0]
dl = oob_dl[1]
if 'Event:' in line:
indx = line.find('Event:') + 7
list.append(line[indx:].strip('\n'))
line = file_object.readline()
line = file_object.readline()
line = file_object.readline()
list.append(oob)
list.append(dl)
if 'Data:' in line:
list.append(line[5:].strip('\n'))
line = file_object.readline()
else:
list.append('NaN')
#Timestamp
list.append(line[11:].strip('\n'))
#Lat
line = file_object.readline()
list.append(line[5:].strip('\n'))
#Lng
line = file_object.readline()
list.append(line[5:].strip('\n'))
line = file_object.readline()
if 'Radius:' in line:
list.append(line[8:].strip('\n'))
else:
list.append('NaN')
#Google maps link
line = file_object.readline()
list.append(line[18:].strip('\n'))
arr.append(list)
#print(list)
list = []
line = file_object.readline()
#print(arr)
df = pd.DataFrame(arr, columns=['Event',
'OOB',
'DL',
'Data',
'Timestamp',
'Lat',
'Lng',
'Radius',
'Gmaps Link'])
csvname = input('Save csv with name: ')
df.to_csv(csvname, sep=',')