Created
December 24, 2018 06:06
-
-
Save adeonhy/8d513983fdbe566abcc5bf5425ecdacc to your computer and use it in GitHub Desktop.
BOOTHの注文データからクリックポストの印字データにするやつ
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' | |
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