Skip to content

Instantly share code, notes, and snippets.

@ashaw
Created July 20, 2012 21:11
Show Gist options
  • Save ashaw/3153250 to your computer and use it in GitHub Desktop.
Save ashaw/3153250 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'fech'
require 'fastercsv'
class Fech2CSV
def initialize
@filing_id = ARGV[0]
@line = ARGV[1]
@filing = Fech::Filing.new(@filing_id)
@filing.download
@lines = @filing.rows_like(/^#{@line}/)
end
def to_csv
FasterCSV.open("/tmp/#{@filing_id}_#{@line}.csv", "w") do |csv|
csv << @lines.first.keys
@lines.each do |line|
csv << line.values
end
end
end
end
if __FILE__ == $0
f = Fech2CSV.new
f.to_csv
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment