I am reading data from a file and extracting the information that I want from it, as floats. I am then storing this data into a temporary list and using vstack to try and put the data into an array with each row being new data that is being processed.
for line in lines:
if line.find('GPS')!=-1:
funcGPS(line)
if line.find('-----')!=-1:
MasterArray = numpy.vstack(temp)
temp = []
#print MasterArray
if line.find('SERVO')!=-1:
funcSERVO(line)
This is how I am trying to copy the data to the array. I am successfully extracting the data and after extracting the data obtained I want to add the data to the array. Currently, it is copying the data over the previous data when I build onto MasterArray. Is there anyway to do this without specifically stating what the size of MasterArray is? I don't want to limit the amount of data that can be obtained.
Thanks!
tempcome from? You can usenp.appendinstead ofnp.vstackinside your loop, or else you can keep adding it to a list and vstack that list after your loop, but you might be better off loading all your data in at once, withnp.genfromtxt, and then editing it.tempis and how it's constructed.vstackaccepts a sequence of arrays, and joins them together. Sotempshould be a tuple or list of arrays to join; if you mean to append toMasterArray, then your definition oftempwill need to look something liketemp = (MasterArray, newrow). This isn't the best approach to dynamic array creation though; see here for more information.