class Sepparator::Console
Public Instance Methods
convert(csv_path, xls_path=nil)
click to toggle source
# File lib/sepparator/console.rb, line 27 def convert(csv_path, xls_path=nil) xls_path ||= csv_path.gsub(/\.csv/, '.xlsx') converter = SpreadsheetConverter.new(col_sep: options['col_sep'] || "\t") File.unlink(xls_path) if File.exists?(xls_path) && options.include?('force') if File.exists?(xls_path) STDERR.puts "destination file exists, use --force to overwrite: #{xls_path}" exit(1) elsif (not File.exists?(csv_path)) STDERR.puts "csv file not found: #{csv_path}" exit(2) end begin converter.convert(csv_path, xls_path) rescue ArgumentError => e STDERR.puts e.message exit(3) end end