Read in Table as a matrix

Dear forum users,
i'm trying to read a table with 40x122 data in a array. Following this, i'd plot each rows again the header of the file in gnuplot.

i was thinking for something like that

#!/bin/bash 
# reads from the $ips file and assigns to $MYARRAY
#IFS =";" split the line after the ;
#set -- $array save the each row of the line in $1 $2 $3 $4 ....

myfile="Comprasion.txt"
ln=`wc -l $myfile|awk '{print $1}'`
i=1
#echo "$ln"
declare -a sgs
for ((i==1; i<=$ln; i++)); do 
         line=`awk "NR==$i" $myfile`
         #echo "$line"
         declare -a row
         linarray=(`echo ${line// / }`);
         #echo "${#linarray
[*]}" # OK.
         #echo "${#linarray
[*]}" # OK.
         row=(`echo ${#linarray
[*]}`);
         echo "*********"
         #echo "$row"
         r=1
         for ((r==1;r<=$row;r++)); do 
            #echo "variable $i $r"; # OK.
            sgs[${i},${r}]=(`echo ${linearray[$r]}`);
            var=${sgs[${i},${r}]};
         echo "$var";
         done
         #echo "$i";
done

if i run the script, unfortunately, i get nothing. Where do i have problem?

thanks in advance for your help

---------- Post updated at 07:26 PM ---------- Previous update was at 03:43 PM ----------

nobody has a suggestion :frowning:

Please post sample input and an example of the desired/expected output.

here is a part of the input file

  Lon    Lat      1990    1991   1992   1993
-10.75  51.25    58.0    51.0    52.6    55.0 #st1
-9.25  40.75    58.0    51.0    52.6    55.0   #st2
-8.25  54.25    74.5    82.2    67.6    67.8   #st3
-7.25  51.75    57.0    55.6    54.8    54.8   #st4
-7.25  51.75    57.0    55.6    54.8    54.8   #st5
-7.25  54.25    79.2    85.2    68.6    74.8    #st6
-6.75  52.75    58.5    66.8    60.8    63.6    #st7
-1.25  50.75    66.5    70.2    63.0    57.0    #st8
-0.75  48.75    67.5    70.0    64.8    58.4    #st9
2.75  50.75    79.5    82.8    74.4    63.2      #st10

i'd like to plot the years on x-axis and the value of st[1..10] on the y-axis with line via gnuplot. Therefore, i need to split the table in a 2 dimensional array as sgs(year,st1..10)

Could you also post an example of the expected output? How the data to be passed to GNU plot should look like?

Hi radoulov,
the output should look like:

1990 58.0
1991 51.0
1992 52.6
1993 55.0
e
1990 58.0
1991 51.0
1992 52.6
1993 55.0
e
1990 74.5
1991 82.2
1992 67.6
1993 67.8
e
end etc.

thank you very much for your help

Assuming the last column (values with a leading #) is not present in the real input:

awk 'NR == 1 {
  n = split($0, y)
  next
  }
{
  for (i = 2; ++i <= NF;)
    print y, $i
  print "e"
  }' infile  

Otherwise:

awk 'NR == 1 {
  n = split($0, y)
  next
  }
{
  for (i = 2; ++i < NF;)
    print y, $i
  print "e"
  }' infile  

Thank you very much it works perfekt