Created
March 10, 2010 21:10
-
-
Save msonnabaum/328404 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 'fastercsv' | |
require 'json' | |
class Cvs2json | |
attr_reader :csv | |
def initialize(filename) | |
@filename = filename | |
@csv = FasterCSV.read(@filename, {:converters => :all} ) | |
end | |
def tojson | |
json_file = File.basename(@filename, '.csv') | |
File.open("#{json_file}.js", 'w') do |f| | |
f.puts(@csv.to_json) | |
end | |
end | |
end | |
b = Cvs2json.new(ARGV[0]) | |
b.tojson |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment