# Creating Arrays

**URL:** <https://www.ruby-forum.com/t/creating-arrays/114806>\
**Category:** Ruby\
**Created:** [September 17, 2007, 6:45pm UTC](https://www.ruby-forum.com/t/creating-arrays/114806 "2007-09-17T18:45:57Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jngo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e95f7d/32.png) [@jngo](https://www.ruby-forum.com/u/jngo)\
**Post date:** [September 17, 2007, 6:45pm UTC](https://www.ruby-forum.com/t/creating-arrays/114806/1 "2007-09-17T18:45:57Z")

</div>

Dear All,\<?xml:namespace prefix = o ns =  
“urn:schemas-microsoft-com:office:office” /\>

Please forgive me if this email is a bit simple, but I am new to ruby  
and object orientated programming pretty much and just looking for a few  
tips from the experts.

I have a .csz file created from a spreadsheet which contains 666 rows  
and 19 columns. What I would like to do is read the csz file into an  
array in ruby and store that array as a set of columns and rows (like in  
excel). Once I have achieved this, I will be making some updates to all  
the figures within the Array.

At the moment my code looks like this:

print “Importing Planning Sheet: 2004\_extrap\_Planning\_Data\n”

filepath = ‘Q:\TECH2006\DBA\02\_LU\Final TAGM 2007  
(working)\TAGM\_666\_Current\_FROM  
G\_DRIVE\2004\2004\_extrap\_Planning\_Data.csv’

Input\_file = File.new(filepath, ‘r’)

puts “READING THE FILE”

fields = Array.new

while ( !Input\_file.eof )

```
        line = Input_file.gets

        line.each(',') { |this_record|

                    fields << this_record.chomp(",").strip()

                     }

```

Input\_file.each { |line| }

End

What I understand is happening is that I am reading my file into a new  
Ruby file called “Input\_file” and then I am creating a new Array called  
“fields” and I am loading the new file into the fields array but  
removing the commas using the chomp in each line. Unfortunately it isn’t  
working!

My question is basically how do I do what I want to do?.. It is  
difficult for a new starter but I suspect you guys would know it inside  
out!

Any tips would be greatly appreciated!

Cheers!

- John

#####################################################################################  
This e-mail message has been scanned for Viruses and Content and cleared  
by MailMarshal  
#####################################################################################
