in reply to Re: How to read each line of a file into a nested array
in thread How to read each line of a file into a nested array

One more quick question ! If my NASTRAN output file was something like this:

1 2 3 4 5

1 20 30 40 50

1 9 3 3 6

4 6 7 9 0

4 4 8 90 8

4 5 2 7 20

9 5 2 7 20

9 20 30 40 50

9 4 8 90 8

The start of each line (The first number) represent an element ID. Would it possible to create a hashes of nested arrays where each element ID is the key for the created nested array. I know it does not make sense, but I need a seperate nested array for each element ID (start of each line) so that I can sort it later on based on a chosen column and print it. I have to get the all the lines that starts with first element put them in a nested array in a way which is described in the first message and later create a hash where the key is the element ID and points to a nested array which has all the information about that particular element. Basically: Element ID (key for the hash) = 1 points to a nested array of

1 '1 2 3 4 5'

1 '1 20 30 40 50'

1 '1 9 3 3 6'

Element ID = (key for the hash) = 4 points to a nested array

4 '4 6 7 9 0'

4 '4 4 8 90 8'

4 '4 5 2 7 20'

Element ID = (key for the hash) = 9 points to a nested array

9 '9 5 2 7 20'

9 '9 20 30 40 50'

9 '9 4 8 90 8'

I am not sure if this is the best way of doing it but I can not think of any other way. Any Help will be appreciated. Thanks a lot.

  • Comment on Re: Re: How to read each line of a file into a nested array