1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| class Camera_Data:
def __init__(self,path_files,files_list,nb_column):
self.nb_files=len(files_list) # Saving the file list
self.files_list=files_list # Saving the file list
for i,file_name in enumerate(files_list): # Iterating over the files lits
# Reading the Data-File
f=open(path_files+file_name,"r") # Opening the file file_name
flines=f.readlines() # Reading the file lines
f.close() # Closing the file file_name
M_file=numpy.zeros((len(flines)-3,nb_column)) # Initialization of the data matrix. Here -3 lines due to the file-headers
for j in range(3,len(flines)): # Iterating over all lines
if (flines[i]!=''): # Line not empty
words=flines[j].split() # Split a line into words spaced with a blank space
for k in range(0,len(words)): # Iterating over all words
M_file[j-3,k]=float(words[k].replace(',','.')) # Converts string into float and replace , to . for decimal point
if (i==0):
self.data=M_file
else :
self.data=numpy.append(self.data,M_file,axis=0) |
Partager