added a dump_csv script
This commit is contained in:
parent
282947de7b
commit
0f39337ffc
2 changed files with 27 additions and 0 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
opensecrets
|
26
dump_csv.rb
Executable file
26
dump_csv.rb
Executable file
|
@ -0,0 +1,26 @@
|
||||||
|
#!/usr/bin/env ruby
|
||||||
|
# dump csv file contents
|
||||||
|
|
||||||
|
require 'csv'
|
||||||
|
require 'optparse'
|
||||||
|
|
||||||
|
# basic commandline parsing
|
||||||
|
options = {}
|
||||||
|
|
||||||
|
parser = OptionParser.new do |parser|
|
||||||
|
parser.banner = "Usage: dump_csv.rb [options]"
|
||||||
|
parser.on("-c", "--column INT", "The column number to dump.") do |column|
|
||||||
|
options[:column] = column
|
||||||
|
end
|
||||||
|
parser.on("-f", "--filename NAME", "The CSV filename to use.") do |filename|
|
||||||
|
options[:filename] = filename
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
parser.parse!
|
||||||
|
|
||||||
|
|
||||||
|
col_data = []
|
||||||
|
CSV.foreach(options[:filename]) {|col| col_data << col[options[:column].to_i]}
|
||||||
|
|
||||||
|
puts col_data
|
Loading…
Add table
Reference in a new issue