import sys
import shutil
import datetime
def main():
'''Main script'''
org = sys.argv[1] + '.bak'
dest = sys.argv[1]
shutil.move(sys.argv[1], org) # Backup
fp = open(org)
fp2 = open(dest, 'w')
print('### HEADER : 11', file=fp2)
print('# VERSION : 1.0', file=fp2)
print('# CREATION_DATE : %s' % datetime.datetime.now().strftime('%FT%T'), file=fp2)
for i in range(8):
fp2.write(fp.readline().replace('=', ':'))
fp.readline() # Skip
print('# DATAFORMAT : Ximg Yimg theta phi Nx Ny Nz f[s3/m6] j[/cm2_sr_eV_s]', file=fp2)
data = fp.readlines()
print('### DATA : 1', file=fp2)
print('## DATA : DATA : %d' % len(data), file=fp2)
for s in data:
print(s.strip(), file=fp2)
print('### TRAIL : 0', file=fp2)
if __name__ == "__main__":
main()