Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
BOOTHの注文データからクリックポストの印字データにするやつ
require 'csv'
CLICKPOST_HEADER = %w(お届け先郵便番号 お届け先氏名 お届け先敬称 お届け先住所1行目 お届け先住所2行目 お届け先住所3行目 お届け先住所4行目 内容品)
booth_order_csv_path = ARGV.shift
booth_order_csv = CSV.read(booth_order_csv_path, 'r:BOM|UTF-8', headers: true)
click_post_data = booth_order_csv.map do |row|
[
row['郵便番号'],
row['氏名'],
'様',
row['都道府県'] + row['市区町村・丁目・番地'],
row['マンション・建物名・部屋番号'],
'',
'',
'キーボード部品',
]
end
clickpost_csv_string = CSV.generate do |csv|
csv << CLICKPOST_HEADER
click_post_data.each {|row| csv << row}
end
puts clickpost_csv_string.encode('CP932', 'UTF-8')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment