Is there a way to force genfromtxt to output data with the shape : (xx, 1) in the case only one column of data is loaded? The usual shape is (xx, ). xx in my example could any integer.
update: here is an example of code:
import numpy as np
a = np.zeros([1000, 10])
nbcols = 1
for ind in range(0, 10, nbcols)
a[:, ind : ind + nbcols] = np.genfromtxt('file_1000x10.csv', usecols = range(nbcols))
this piece of code works only for nbcols >= 2; assuming nbcols is an integer c [1, 10]. is there a solution to make it work for nbcols = 1 without adding an if statement.
In fact I simplified too much the original code for this post, though that wouldn't affect the answers to my problem. In fact the filename is given through a variable as following:
filename = 'file_1000x10_' + '%02d' % ind.astype(int) + '.csv'
So at each iteration in the for loop, np.genfromtxt loads data from another file.