Problem

Consider this formatted data file: data.in. Write a simple script named formatted2csv that takes two input arguments representing the input and output file names. Then, the script writes the same input float data to the output file data.out in a comma-separated (CSV) style, like this example output file.

Python

Write your Python script in such a way that it takes the input and output file names from the Bash command line arguments, like the following,

python formatted2csv.py data.in data.out
MATLAB

Write your MATLAB script as a function that takes the input and output file names as input arguments to a function named formatted2csv, so that it can be called like the following from the MATLAB command line.

formatted2csv('data.in','data.matlab.out')

Solution

The solution to this problem is simply the inverse of the solution to Data transfer: Converting Comma-Separated-Values (CSV) input to formatted output.

Comments