Skip to content

Instantly share code, notes, and snippets.

@supriya
Created August 28, 2009 21:39
Show Gist options
  • Save supriya/177280 to your computer and use it in GitHub Desktop.
Save supriya/177280 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'rubygems'
require 'fileutils'
require 'fastercsv'
csv_data = []
arr = Array.new
input_file= FasterCSV.open("input.csv", "r")
input_file.each_line { |line|
csv_data = line.split(',')
csv_data[1].tr_s("$","").split
csv_data[1].tr_s(",","").split
csv_data[2] = csv_data[2].match(/^(\d{2})(\d{2})(\d{4})$/)
csv_data[2] = "#{csv_data[2][2]}/#{csv_data[2][1]}/#{csv_data[2][3]}"
arr.push(csv_data)
}
input_file.close
output_file = FasterCSV.open("output.csv", "w") do |csv|
@arr.each do |array|
csv << array
end
end
output_file.close
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment