I often work with data stored in text files with [x, y, z] like format. When loading the data into a NumPy array, it is convenient to maintain the ordering from the text file, where each column is a different element, x, y, or z. The downside to this is with the C ordering NumPy uses as the default, operating on all the x-values mean accessing non-contiguous memory blocks.
To load the data into a Fortran ordered array, I can use
data = numpy.asfortranarray(numpy.loadtxt('data.txt'))
but is there a way to do that in one line? Looking at the loadtxt documentation, this method does not seem to provide that functionality. Is there an another load function that does?
loadtxtcan allocate memory for a row but not for a column beforehand? So the best it could do is read the array in C order and then convert it to F order.