Sha256: 75299d66dd58e4beb87f097d9ef66f368e10cb38e93e7f511f70f32e252ae3e5
Contents?: true
Size: 828 Bytes
Versions: 1
Compression:
Stored size: 828 Bytes
Contents
#!/usr/bin/env ruby require 'bundler/setup' require 'streamer' require 'csv' require 'pry' # create a base document to house the sales data sales_numbers = { 'name' => 'example sales filtering and calculation', 'sales' => [] } # load sales data from a csv and place it into the document data_file_path = File.join(__dir__, 'data.csv') CSV.foreach(data_file_path, headers: true) do |row| sales_numbers['sales'] << row.to_hash end # configure a new stream, loading the configuration from a file config_file_path = File.join(__dir__, 'sb_config.yml') sb = Streamer::StreamBuilder.new(YAML.load_file(config_file_path)) # process the data document using the configured stream sb.process(sales_numbers) # output the results to stdout sb.payload['summary']['sales_by_product'].each do |k, v| printf "%-20s %d\n", k, v end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
streamer-0.2.1 | examples/example1/example.rb |