From: Alex Young Date: 2007-05-29T06:24:44+09:00 Subject: Re: Trying to decide on a language to learn Crep Cat wrote: > I am trying to decide on a language to learn - and would be grateful for > help. > My reasons for wanting to learn programming are firstly to have fun > and secondly to learn more about how computers work. > > I have thought of one thing I would like to write - and wonder if Ruby > (or perhaps Python?) would be suitable. > > I would like to export a spreadsheet column to a file; > read that file into Ruby as an array; > mess about with that array; > write the new array out as a file; > import that file into a spreadsheet. > > I can't understand the documentation about file handling. > Ruby documentation starts off very user friendly, > but, by the time it gets to file handling, has become extremely esoteric! > > Anyway, would Ruby be a good language for that task? Yes. There is a library included with Ruby specifically for this sort of task - it's the CSV library. Mind you, if you're dealing with files that only contain a single column, there's going to be a simpler way to do it. > Would any other language be more suitable? For tasks of this sort of complexity, Ruby, Python and Perl are probably equivalent - there's not a lot in it. > Could I get newbie help on file handling here? Certainly - but it's always best to have as specific a problem as possible, and to show us what you've already tried and what you're expecting the code to do. > Is there a really good introductory book which deals simply with file > handling? The Pickaxe is the definitive guide - there's a free edition online here: http://www.ruby-doc.org/docs/ProgrammingRuby/. The section you want is "Basic Input and Output". You'll also want to read the "Containers, Blocks, and Iterators" section to get a handle on blocks - lots of Ruby is based around blocks, so it's good to know how they work. Hope this helps, -- Alex