I am trying to import a lower triangular matrix into pandas (or numpy) in Python in order to convert it into a symmetrical square matrix but I am stuck at the import step.
The matrix has the first column with names but the rest of the columns are numbers in a tab delimited format like this:
A
B 1
C 10 20
D 21 25 45
I get error when I try to import it using numpy:
myfile = np.genfromtxt("trimatrix.txt", delimiter="\t")
and also when I use pandas:
myfile = pd.read_table("trimatrix.txt")
In both cases, the errors are because there is only one column after reading the first row but the other rows have more columns.
Thank you for your time and help!