No BSD License  

Highlights from
csvwriteFast

Be the first to rate this file! 3 Downloads (last 30 days) File Size: 327 Bytes File ID: #21645

csvwriteFast

by Sergey

 

30 Sep 2008 (Updated 03 Oct 2008)

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

| Watch this File

File Information
Description

usage:
csvwriteFast( filename, values, format )

speed:
>> 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.

MATLAB release MATLAB 7.5 (R2007b)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (1)
21 Oct 2008 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 );

Please login to add a comment or rating.
Updates
03 Oct 2008

updating the help

Tag Activity for this File
Tag Applied By Date/Time
data import Sergey 22 Oct 2008 10:22:17
data export Sergey 22 Oct 2008 10:22:17
csvwrite Sergey 22 Oct 2008 10:22:17
utilities Sergey 22 Oct 2008 10:22:18
dlmwrite Sergey 22 Oct 2008 10:22:18
data Sergey 22 Oct 2008 10:22:18
import Sergey 22 Oct 2008 10:22:18
export Sergey 22 Oct 2008 10:22:18

Contact us at files@mathworks.com