The data in my case are 2D arrays available in multiple files. In the end, I would like to append these 2D arrays row-wise. For example, say fileA contains
1 2 3
4 5 6
and fileB contains
7 8 9
0 1 2
I would like the resulting operation to be
1 2 3
4 5 6
7 8 9
0 1 2
The easiest way to do this is as per the solution here something like
data = np.concatenate([np.loadtxt(f) for f in filenames])
However, I would like to include a column during this operation. For example, let x = [3, 5] with length of x = number of files. Each file's row length is fixed (and in this case is 2). I would like the resulting array to be:
3 1 2 3
3 4 5 6
5 7 8 9
5 0 1 2
How to achieve this in a pythonic way?