Sha256: 24bc3434171163ea88736f86a2ceae46f33f1f9f4013e32fc62805796b0cf0f0

Contents?: true

Size: 558 Bytes

Versions: 12

Compression:

Stored size: 558 Bytes

Contents

# convert input to clean standard CSV
require "csv"

class Masticate::Csvify < Masticate::Base
  def initialize(filename)
    @filename = filename
  end

  def csvify(opts)
    standard_options(opts)

    @output_count = 0
    with_input do |input|
      while line = get
        row = CSV.parse_line(line, csv_options)
        if row
          row = row.map {|s| s && s.strip}
          emit(row)
        end
      end
    end
    @output.close if opts[:output]

    {
      :input_count => input_count,
      :output_count => @output_count
    }
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
masticate-0.6.2 lib/masticate/csvify.rb
masticate-0.6.1 lib/masticate/csvify.rb
masticate-0.6.0 lib/masticate/csvify.rb
masticate-0.5.1 lib/masticate/csvify.rb
masticate-0.5.0 lib/masticate/csvify.rb
masticate-0.4.2 lib/masticate/csvify.rb
masticate-0.4.1 lib/masticate/csvify.rb
masticate-0.4.0 lib/masticate/csvify.rb
masticate-0.3.2 lib/masticate/csvify.rb
masticate-0.3.1 lib/masticate/csvify.rb
masticate-0.3 lib/masticate/csvify.rb
masticate-0.2.3 lib/masticate/csvify.rb