#!/usr/bin/python
# will take as a single argument the name of a ccwin tmp file
# which is the results of the simulation in a binary file
# and save a copy as a CSV file that can be readily
# read with matlab or excel
import numpy as np
import os
import sys
filename=sys.argv[1]
fileparts=os.path.splitext(filename)
f=open(filename)
data=np.fromfile(f,'<f4')
f.close()
columns=21 # num of columns in ccwin results file
rows=np.shape(data)[0]/columns
data2=data.reshape(rows,columns)
np.savetxt(fileparts[0]+'.csv',data2,delimiter=',')
