Created
May 24, 2016 21:41
-
-
Save mscoutermarsh/95fd9b1490fe87d8d042ad45cdfccf6d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'csv' | |
require 'pry' | |
orders = CSV.read('orders.csv', headers: true) | |
output = open('output.csv', 'w') | |
output.truncate(0) | |
output.write("order_id, quantity, shipping_address\n") | |
orders.each do |row| | |
next if row['Type'] != 'sku' | |
output.write("#{row['Order']},") | |
output.write("#{row['Quantity']},") | |
output.write("\"#{row['Shipping Name']}\n") | |
output.write("#{row['Shipping Address Line1']}\n") | |
output.write("#{row['Shipping Address Line2']}\n") unless row['Shipping Address Line2'].empty? | |
output.write("#{row['Shipping Address City']}, #{row['Shipping Address State']} #{row['Shipping Address Postal Code']}\"") | |
output.write("\n") | |
end | |
output.close |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment