I have a file containing data in the format:
0.0 x1
0.1 x2
0.2 x3
0.0 x4
0.1 x5
0.2 x6
0.3 x7
...
The data consists of multiple datasets, e
You don't need a python loop to evaluate the locations of each split. Do a difference on the first column and find where the values decrease.
import numpy
# read the array
arry = numpy.fromfile(file, dtype=('float, S2'))
# determine where the data "splits" shoule be
col1 = arry['f0']
diff = col1 - numpy.roll(col1,1)
idxs = numpy.where(diff<0)[0]
# only loop thru the "splits"
strts = idxs
stops = list(idxs[1:])+[None]
groups = [data[strt:stop] for strt,stop in zip(strts,stops)]