Akil Kumar wrote:
How can I index multiple columns of variable length while reading a CSV file? Let's say I have col A, col B, col C and so on. I want to create a 2D array with col A & B then col A & C then col A & D and so on. Moreover can any of the columns contain empty cells in between? Please help me how to achieve this?
I don't see where creating a transpose matrix comes into this and don't fully understand the requirement but it seems to me you need to use the Facade
pattern. Having created your 2 D array from the CSV file you then define a class along the lines of
which defines a mapping between the cols of the original and the desired and an access method to do the conversion.
It is trivial to add methods to return the number of rows and the number of columns. It is trivial to modify the getElement() method to handle non-existent rows or columns.
You then us this as
then use the access getElement() method to access the pseudo matrix.