Read as many rows into memory as you can. Append each column to a separate output file (you'll have to close the file afterwards, because you can't hold 460000 file handles open). After processing the whole input file, read the column files in order to get the matrix transpose. Take the lower triangle of that and combine with the upper triangle of the original.