I am trying to concatenate a set of numpy arrays loaded from disk. All arrays have varying number of columns.
This is my code
import numpy as np
FILE_LIST = ["matrix a", "matrix b"]
result=np.array([[0,0],[0,0]]) # I need to avoid this zero matrix
for fileName in FILE_LIST:
matrix = matrix= np.genfromtxt(fileName, delimiter=" ")
result = np.concatenate((result, matrix),axis=1)
print result
Here I have initialised result to an array with zeroes as I cannot concatenate to an empty array. I need to avoid this zero array appended at the beginning of the result. How to achieve this?