From: John Nott Date: 2007-10-08T20:35:43+09:00 Subject: MATRIX PROBLEMS (AGAIN!) ------_=_NextPart_001_01C8099F.354D0830 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi everyone,=20 As a complete new comer to Ruby. I have written this little piece of simp= le code but I have no idea why it only half works. It creates the matrix = as I want it to but instead of populating it using the file as pointed to= =20in file path, it fills it up with empty data!? =20 If anyone has any tips on where I may be going wrong I would really reall= y appreciate it! I have remmed the code as best as I can throughout. =20 =20 =20 print "Importing Planning Sheet: 2004_extrap_Planning_Data\n" =20 filepath =3D 'Q:\\TECH2006\\DBA\\02_LU\\Final TAGM 2007 (working)\\TAGM_6= 66_Current_FROM G_DRIVE\\2004\\2004_extrap_Planning_Data.csv' #the = file that contains teh data that i would like to put into the matrix=20 =20 file =3D File.new(filepath, 'r') # define new file as file= path =20 mat1 =3D OtMatrix.new(649,19) # define new omni trans matrix 649= =20rows, 19 columns =20 fields =3D Array.new # define fields as a new ar= ray to hold data =20 r =3D 1 # matrix row r =3D fir= st row n =3D 0 # n (fields) =3D 0 c =3D 1 # matric column 1 =3D f= irst column =20 while ( !file.eof ) =20 =20line =3D file.gets =20line.each(',') { |this_record| =20 fields << this_record.chomp(",").strip() # read to the end= =20of the file into 'fields', split into lines and chomp out the delimite= r =20 mat1[r,c] =3D fields[r,c] # the r= ows and columns in the matrix =3D rows and columns in fields =20 c=3Dc+1 =20 =20 n=3Dn+1=20 =20if c > 19 then # loops= =20through each row/column. At the end of each line where c=3D19, reset l= oop onto next row with col =3D 1 =20c =3D 1=20 =20end =20 } =20=20 end =20 print mat1 =20 =20 =20 =20 Thanks very much in advance! =20 =20 #########################################################################= ############ This e-mail message has been scanned for Viruses and Content and cleared = by MailMarshal #########################################################################= ############ ------_=_NextPart_001_01C8099F.354D0830--