異なるメールアドレスを持つ1001件のcsvファイルを作成する【追記】

20170531追記

csvにより入力された「異なるメールアドレスを持つ顧客データ」を1ページあたり 1000件まで表示させるチケットがあり、境界の値周辺で挙動がおかしかったので1001件のデータを与えました。ただ1001件のデータがなく、かつ上限の変数もclassファイルとなって操作できないので、pythonでcsvを作ってみました。

第一項に出力ファイル名、第二項に生成する行の数です。適宜output_file.writeの中身をコメントアウトして使いました。


import sys argvs = sys.argv arglength = len(argvs) print(argvs[1]) print(argvs[2]) try: out = argvs[1] with open(out,"w") as output_file: for i in range(int(argvs[2])): output_file.write("%s@gmail.com,a,smith,paul,smith,paul,99-99-91,1001,111-1111-1111,,,,\n"%(i)) except IndexError: print(""" you might want to put two items: 1:the name of the output file 2:the number of the addresses""")

意外とレビュー中に使用頻度が高かったです。