parent
0d5ac582c7
commit
d67d31cd27
|
|
@ -0,0 +1,2 @@
|
||||||
|
.idea
|
||||||
|
__pycache__
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
__author__ = 'dmy'
|
||||||
|
|
||||||
|
from reader import *
|
||||||
|
|
||||||
|
if __name__=='__main__':
|
||||||
|
ieeeData=IEEEData('IEEE4.dat')
|
||||||
|
print('Finished.')
|
||||||
|
|
@ -0,0 +1,26 @@
|
||||||
|
__author__ = 'dmy'
|
||||||
|
|
||||||
|
import numpy
|
||||||
|
|
||||||
|
class IEEEData:
|
||||||
|
def __init__(self,filePath,seperator='\t'):
|
||||||
|
self._filePath=filePath
|
||||||
|
self._seperator=seperator
|
||||||
|
self._read()
|
||||||
|
def _convertToVector(self,lineVec):#把数据文件按分隔符存成矩阵,像Matlab一样。
|
||||||
|
self._array=numpy.array(lineVec)
|
||||||
|
print(lineVec)
|
||||||
|
print(self._array[0])
|
||||||
|
|
||||||
|
def _read(self):
|
||||||
|
lineVec=[]
|
||||||
|
with open(self._filePath,'tr') as f:
|
||||||
|
for line in f:
|
||||||
|
if len(line.strip())==0:
|
||||||
|
continue
|
||||||
|
lineVec.append([float(x) for x in line.split(self._seperator)])
|
||||||
|
self._convertToVector(lineVec)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Loading…
Reference in New Issue