From: John Nott Date: 2007-09-18T01:43:57+09:00 Subject: Creating Arrays.... ------_=_NextPart_001_01C7F947.B0336160 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Dear All, Please forgive me if this email is a bit simple, but I am new to ruby and= =20object orientated programming pretty much and just looking for a few t= ips from the experts.=20 =20 I have a .csz file created from a spreadsheet which contains 666 rows and= =2019 columns. What I would like to do is read the csz file into an array= =20in ruby and store that array as a set of columns and rows (like in exc= el). Once I have achieved this, I will be making some updates to all the = figures within the Array. =20 At the moment my code looks like this: =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' =20 Input_file =3D File.new(filepath, 'r') =20 =20 puts "READING THE FILE" =20 fields =3D Array.new =20 while ( !Input_file.eof ) =20 line =3D Input_file.gets =20 =20 =20 line.each(',') { |this_record| =20 fields << this_record.chomp(",").strip() =20 } =20 Input_file.each { |line| } =20 End =20 =20 What I understand is happening is that I am reading my file into a new Ru= by file called "Input_file" and then I am creating a new Array called "fi= elds" and I am loading the new file into the fields array but removing th= e commas using the chomp in each line. Unfortunately it isn't working! =20 My question is basically how do I do what I want to do?... It is difficul= t for a new starter but I suspect you guys would know it inside out! =20 Any tips would be greatly appreciated! =20 Cheers! =20 - John =20 =20 #########################################################################= ############ This e-mail message has been scanned for Viruses and Content and cleared = by MailMarshal #########################################################################= ############ ------_=_NextPart_001_01C7F947.B0336160--