-
Notifications
You must be signed in to change notification settings - Fork 0
/
Napture.py
33 lines (28 loc) · 1.06 KB
/
Napture.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
# -*- coding: UTF-8 -*-
import pandas as pd
class Napture(object):
def __init__(self):
self.filename = None
self.file = None
def open(self, filename, encoding=None):
self.filename = filename
self.file = open(self.filename, 'r', buffering= -1, encoding = encoding)
def getdata(self):
tmp = open(self.filename, 'r', buffering=-1, encoding = 'ascii')
count = -1
for count,line in enumerate(tmp):
index = line.split()[:10]
if 'Cycle' in index:
break
count += 1
tmp.close()
i = 0
dataframe = pd.DataFrame(data = None,index = None,columns = index)
for line in open(self.filename,'r', buffering = -1,encoding = 'ascii'):
if i >= count + 1:
data = line.split()[:10]
if '***' in data:
break
dataframe = dataframe.append(pd.DataFrame(data = [data], columns = index),ignore_index = True)
i += 1
return dataframe.iloc[:,2:].astype(float)