Sha256: 039d98255a80ef39940872ed1a6cf78a4d17cb41cf9ceebb77e2a64ea09ff0e7

Contents?: true

Size: 598 Bytes

Versions: 6

Compression:

Stored size: 598 Bytes

Contents

#!/usr/bin/env ruby
$:.unshift File.join( File.dirname(__FILE__), "..", "lib")

require 'csvlint'

begin
  puts ARGV[0]
  csv = CSV.new( URI.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

6 entries across 6 versions & 1 rubygems

Version Path
csvlint-1.5.0 bin/create_schema
csvlint-1.4.0 bin/create_schema
csvlint-1.3.0 bin/create_schema
csvlint-1.2.0 bin/create_schema
csvlint-1.1.0 bin/create_schema
csvlint-1.0.0 bin/create_schema