From: "Jan E." Date: 2012-04-19T22:05:01+09:00 Subject: Re: Converting CSV cristian cristian wrote in post #1057358: > How can I use an array of file names from the directory to use it when > creating the new csv's? > > I was thinking something like this: > > files = Dir.glob("*.csv") > > files.each |filename| > > file.open (filename+"_converted.csv",'w') do |csv| > [...] You should strip the ".csv" extension from filename. Otherwise, you'll end up with names like "myfile.csv_converted.csv". For example: "#{filename[0...-4]}_converted.csv" Also it doesn't really make sense to save the Dir#glob Enumerator in files (unless you want to use it again). Simple write it as one continuous expression: Dir.glob("*.csv") do |file| ... end -- Posted via http://www.ruby-forum.com/.