just messing around with different ways to parse the arguments
This commit is contained in:
parent
a40a8c90e8
commit
f7ddfdebe3
1 changed files with 5 additions and 5 deletions
10
dump_csv.rb
10
dump_csv.rb
|
@ -12,18 +12,18 @@ parser = OptionParser.new do |parser|
|
||||||
parser.on("-c", "--column int", "The column number to dump.") do |column|
|
parser.on("-c", "--column int", "The column number to dump.") do |column|
|
||||||
options[:column] = column
|
options[:column] = column
|
||||||
end
|
end
|
||||||
parser.on("-f", "--filename NAME", "The CSV filename to use.") do |filename|
|
parser.on("-f", "--filename FILE", "The CSV filename to use.") do |filename|
|
||||||
options[:filename] = filename
|
options[:filename] = filename
|
||||||
end
|
end
|
||||||
|
options[:all] = false
|
||||||
parser.on("-a", "--all", "Dump all columns") do
|
parser.on("-a", "--all", "Dump all columns") do
|
||||||
options[:all] = truejj
|
options[:all] = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
parser.parse!
|
parser.parse!
|
||||||
|
|
||||||
#if options[:column].is_a?
|
|
||||||
col_data = []
|
col_data = []
|
||||||
CSV.foreach(options[:filename]) {|col| col_data << col[options[:column].to_i]}
|
|
||||||
|
CSV.foreach (options[:filename]) {|col| col_data << col[options[:column].to_i]} if (options[:column] and options[:filename])
|
||||||
puts col_data
|
puts col_data
|
||||||
#end
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue