Created
September 21, 2010 13:56
-
-
Save rorcraft/589717 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'rubygems' | |
require 'roo' | |
pwd = File.dirname(__FILE__) | |
Dir.glob("#{pwd}/*.xls") do |file| | |
file_path = "#{pwd}/#{file}" | |
file_basename = File.basename(file, ".xls") | |
xls = Excel.new(file_path) | |
xls.to_csv("#{pwd}/#{file_basename}.csv") | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi Man thanks for this snippet of code. when I ran it I got the below error
rooxls2csv.rb:10:in
'block in <main>': uninitialized constant Excel (NameError) from rooxls2csv.rb:7:in
glob'from rooxls2csv.rb:7:in `
I fixed it by adding Roo::Excel...... check below.
!/usr/bin/env ruby
require 'rubygems'
require 'roo'
pwd = File.dirname(FILE)
Dir.glob("#{pwd}/*.xls") do |file|
file_path = "#{pwd}/#{file}"
file_basename = File.basename(file, ".xls")
xls =Roo::Excel.new(file_path)
xls.to_csv("#{pwd}/#{file_basename}.csv")
end