Amazon未出荷レポート→クリックポストCSV変換
動機
クリックポストのCSVを作るのが手作業で、くっそメンドクサイ。
手を抜きたい。
概要
Amazon未出荷レポートを、スクリプトにドラッグ&ドロップすれば、クリックポストCSVの形式に自動変換してくれるスクリプト。
未改良点:自分用のため、敬称「様」、内容品「書籍」が固定。
Python3.6.1
スクリプト convert_addr.py
# coding: UTF-8
import sys
import csv
from time import sleep
if len(sys.argv) != 2:
print('usage: drop input_file to convert_addr.py')
sleep(3.0)
sys.exit()
input_file = sys.argv[1]
data = []
with open(input_file) as f:
reader = csv.reader(f)
for row in reader:
data.append(row[0].split('\t'))
post_list = []
name_list = []
adr1_list = []
adr2_list = []
adr3_list = []
adr4_list = []
### SETTING ###
NAME_COL = 16
POST_COL = 22
ADR1_COL = 21
ADR2_COL = 17
ADR3_COL = 18
ADR4_COL = 19
###############
for x in data:
name_list.append(x[NAME_COL])
post_list.append(x[POST_COL])
adr1_list.append(x[ADR1_COL])
adr2_list.append(x[ADR2_COL])
adr3_list.append(x[ADR3_COL])
adr4_list.append(x[ADR4_COL])
post_list[0] = 'お届け先郵便番号'
name_list[0] = 'お届け先氏名'
dear = 'お届け先敬称'
adr1_list[0] = 'お届け先住所1行目'
adr2_list[0] = 'お届け先住所2行目'
adr3_list[0] = 'お届け先住所3行目'
adr4_list[0] = 'お届け先住所4行目'
cont = '内容品'
with open('out.csv', 'w', newline='') as f:
write = csv.writer(f)
write.writerow([post_list[0], name_list[0], dear, adr1_list[0], adr2_list[0], adr3_list[0], adr4_list[0], cont])
i = 1
while i < len(name_list):
write.writerow([post_list[i], name_list[i], '様', adr1_list[i], adr2_list[i], adr3_list[i], adr4_list[i], '書籍'])
i += 1
# coding: UTF-8
import sys
import csv
from time import sleep
if len(sys.argv) != 2:
print('usage: drop input_file to convert_addr.py')
sleep(3.0)
sys.exit()
input_file = sys.argv[1]
data = []
with open(input_file) as f:
reader = csv.reader(f)
for row in reader:
data.append(row[0].split('\t'))
post_list = []
name_list = []
adr1_list = []
adr2_list = []
adr3_list = []
adr4_list = []
### SETTING ###
NAME_COL = 16
POST_COL = 22
ADR1_COL = 21
ADR2_COL = 17
ADR3_COL = 18
ADR4_COL = 19
###############
for x in data:
name_list.append(x[NAME_COL])
post_list.append(x[POST_COL])
adr1_list.append(x[ADR1_COL])
adr2_list.append(x[ADR2_COL])
adr3_list.append(x[ADR3_COL])
adr4_list.append(x[ADR4_COL])
post_list[0] = 'お届け先郵便番号'
name_list[0] = 'お届け先氏名'
dear = 'お届け先敬称'
adr1_list[0] = 'お届け先住所1行目'
adr2_list[0] = 'お届け先住所2行目'
adr3_list[0] = 'お届け先住所3行目'
adr4_list[0] = 'お届け先住所4行目'
cont = '内容品'
with open('out.csv', 'w', newline='') as f:
write = csv.writer(f)
write.writerow([post_list[0], name_list[0], dear, adr1_list[0], adr2_list[0], adr3_list[0], adr4_list[0], cont])
i = 1
while i < len(name_list):
write.writerow([post_list[i], name_list[i], '様', adr1_list[i], adr2_list[i], adr3_list[i], adr4_list[i], '書籍'])
i += 1
Author And Source
この問題について(Amazon未出荷レポート→クリックポストCSV変換), 我々は、より多くの情報をここで見つけました https://qiita.com/yu_bookstore/items/89ac156710bf24287217著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .