import csv
import pandas as pd
#文字又は数値を指定幅で結合する
def mix_format(s_list,width):
ostr = ""
fe1 = '{:>' + str(width) + 's}'
fe2 = '{:' + str(width) + 'd}'
for s in s_list:
if type(s) is str:
ostr += fe1.format(s)
else:
ostr += fe2.format(s)
return ostr
df = pd.read_csv('input.csv', sep=',',header=0)
with open('output.txt',"w") as fw:
line0 = mix_format(list(df.columns),10)
fw.write(line0+'\n') #ヘッダ
for i in df.index: #全行分繰り返す
line1 = mix_format(list(df.iloc[i]),10)
fw.write(line1+'\n') #各行データ
aW1wb3J0IGNzdgppbXBvcnQgcGFuZGFzIGFzIHBkCiPmloflrZflj4jjga/mlbDlgKTjgpLmjIflrprluYXjgafntZDlkIjjgZnjgosKZGVmIG1peF9mb3JtYXQoc19saXN0LHdpZHRoKToKICAgIG9zdHIgPSAiIgogICAgZmUxID0gJ3s6PicgKyBzdHIod2lkdGgpICsgJ3N9JwogICAgZmUyID0gJ3s6JyArIHN0cih3aWR0aCkgKyAnZH0nCiAgICBmb3IgcyBpbiBzX2xpc3Q6CiAgICAgICAgaWYgdHlwZShzKSBpcyBzdHI6CiAgICAgICAgICAgIG9zdHIgKz0gZmUxLmZvcm1hdChzKQogICAgICAgIGVsc2U6CiAgICAgICAgICAgIG9zdHIgKz0gZmUyLmZvcm1hdChzKQogICAgcmV0dXJuIG9zdHIKCgpkZiA9IHBkLnJlYWRfY3N2KCdpbnB1dC5jc3YnLCBzZXA9JywnLGhlYWRlcj0wKQp3aXRoIG9wZW4oJ291dHB1dC50eHQnLCJ3IikgYXMgZnc6CiAgICBsaW5lMCA9IG1peF9mb3JtYXQobGlzdChkZi5jb2x1bW5zKSwxMCkKICAgIGZ3LndyaXRlKGxpbmUwKydcbicpICAgICAgI+ODmOODg+ODgAogICAgZm9yIGkgaW4gZGYuaW5kZXg6ICAgICAgICAj5YWo6KGM5YiG57mw44KK6L+U44GZCiAgICAgICAgbGluZTEgPSBtaXhfZm9ybWF0KGxpc3QoZGYuaWxvY1tpXSksMTApCiAgICAgICAgZncud3JpdGUobGluZTErJ1xuJykgICPlkITooYzjg4fjg7zjgr8KCg==