File Exchange

image thumbnail


version 1.0 (327 Bytes) by

fast writing of numerical data / matrices into a csv / text file

1 Download


No License

csvwriteFast( filename, values, format )

>> r = randn( 1e5, 2 );
>> tic, csvwrite( 'r.csv', r ), toc
Elapsed time is 3.945658 seconds.
>> tic, csvwriteFast( 'r.csv', r, '%f,%f' ), toc
Elapsed time is 0.302832 seconds.

another advantage is ability to specify the numerical format for each column separately

i've noticed that this approach is more significant on matrices with low number of columns. For example, it writes matrix with 10 columns merely 3 times faster than csvwrite, while in the example above (2 columns) this factor is over 13.

Comments and Ratings (1)

Thierry Dalon

This is the function:
function csvwriteFast( filename, values, format )
% values: numeric matrix
% format: C format, separate for each column of values.
% example:
% r=randn(1e5,3);
% csvwriteFast( 'r.csv', r, '%f,%f,%f' )

format = [ format, '\n' ];
fid = fopen( filename, 'w' );
fprintf( fid, format, values' );
fclose( fid );

MATLAB Release
MATLAB 7.5 (R2007b)

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video