Skip to content

Instantly share code, notes, and snippets.

# the processed file here will be copied to the new transform below
transform = B2CLinkTransform.create!(output_uri: 's3://axle-legacy-importer-qa/b2c_link/2020-08-03')
drop = transform.s3_drops.create!(base_uri: 's3://axle-tmp/execureach/2020-08-03', transformer_type: 'DataTransforms::B2CLink::ExecureachTransformer')
s3_file = drop.s3_files.create!(file_name: 'execureach_01.csv.gz', completed: true)
processed_file = s3_file.processed_files.create!(file_name: 'execureach_01_0000.csv.gz', records: 500)
new_transform = B2CLinkTransform.build("2020-06-04", ["s3://axle-consumer/emaildb/2020-06-04/"])
ActiveRecord::Base.transaction do
new_transform.save!
@matthinea
matthinea / execureach_encoding_test.rb
Created August 14, 2020 18:19
Test execureach encoding
row_lookup_hash = DataTransforms::B2CLink::Execureach::INPUT_HEADERS.each.with_index.to_h.freeze
iterator = DataTransforms::CsvIterator.new(row_lookup_hash)
transformer = DataTransforms::B2CLink::ExecureachTransformer
exporter = S3File::CsvExporter.new
iterator.each_lines('/Users/matthew/Library/Preferences/RubyMine2019.3/scratches/scratch.csv.gz') do |line|
transformed_line = transformer.new(line).attributes
puts transformed_line
formatted_line = exporter.format_line(transformed_line)
unless formatted_line.valid_encoding?