From: Zoe Phoenix Date: 2009-02-13T13:45:28+09:00 Subject: help reading data from a file I have a ruby program that I use to generate text files from a single array's data, but what I would like to do is be able to have it generate files from multiple arrays and save them in a different folder when it starts writing files from a different array. One problem I'm facing is how to read an array from a file. If I have a file with an only an array in it, how do I apply a method such as ".generate" to the array? Do I name the array inside the file, such as "array1" and then apply the method ".generate"? Or can it be applied to the file itself, such as "file1.generate"? cities = ['Nashville', 'Orlando', 'Tampa' 'Memphis' ] cities.each do |city| output = %Q(#{city}) ###################################### # #Saves File. # ###################################### File::open("C:\\Documents And Settings\\Administrator\\Desktop\\city\\#{city.downcase.delete(' ')}.txt", 'w') do |f| f.write output end end I'm not sure of the best way to expand this code to have it generate files for multiple arrays and have each array's generated files be saved in a separate folder instead of all of them together. To keep from having 1 huge file, I'd like to have each array in a different file, but if this isn't the best way to do it, can someone give me a better example..? -- Posted via http://www.ruby-forum.com/.