Sha256: 5b68e4c3e1d87ce85466c9ec961b07920b8049188e82cdc3cb9cf3c578a993da
Contents?: true
Size: 592 Bytes
Versions: 18
Compression:
Stored size: 592 Bytes
Contents
#!/usr/bin/env ruby $:.unshift File.join( File.dirname(__FILE__), "..", "lib") require 'csvlint' begin puts ARGV[0] csv = CSV.new( open(ARGV[0]) ) headers = csv.shift name = File.basename( ARGV[0] ) schema = { "title" => name, "description" => "Auto generated schema for #{name}", "fields" => [] } headers.each do |name| schema["fields"] << { "name" => name, "title" => "", "description" => "", "constraints" => {} } end $stdout.puts JSON.pretty_generate(schema) rescue => e puts e puts e.backtrace puts "Unable to parse CSV file" end
Version data entries
18 entries across 18 versions & 3 rubygems