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

Version Path
csvlint-0.4.0 bin/create_schema
csvlint-0.3.3 bin/create_schema
csvlint-0.3.2 bin/create_schema
csvlint-0.3.1 bin/create_schema
csvlint-0.3.0 bin/create_schema
wjordan213-csvlint-0.2.8 bin/create_schema
wjordan213.csvlint-0.2.8 bin/create_schema
csvlint-0.2.6 bin/create_schema
csvlint-0.2.5 bin/create_schema
csvlint-0.2.4 bin/create_schema
csvlint-0.2.2 bin/create_schema
csvlint-0.2.1 bin/create_schema
csvlint-0.2.0 bin/create_schema
csvlint-0.1.4 bin/create_schema
csvlint-0.1.3 bin/create_schema
csvlint-0.1.1 bin/create_schema
csvlint-0.1.0 bin/create_schema
csvlint-0.0.1 bin/create_schema