Writing a huge table to a text file is taking a very long time (R2013b)

2 views (last 30 days)
Hallo everyone, I have a table of 1,400,000 rows and 13 columns. 3 columns have integer data, 1 has string data and the others have double data. calculations on table columns are quick, but it takes 18 minutes (!) writing it to a text file with the "writetable" function (using a tab as delimiter).
I tried to use a loop with fprintf'ing each row, but I got an error message: fprintf doesn't work with tables.
Is there a way to speed up things in writing?
Thanks in advance.
Alessandro
  1 Comment
Ivan
Ivan on 21 Jul 2014
I am struggling with the same problem. Here is sample code to illustrate it:
test = (1:1000000)';
testT = table(test);
fprintf(1, 'time: %s\n', datestr(now));
writetable(testT, 'C:\TEMP\testT.csv');
fprintf(1, 'time: %s\n', datestr(now));
save('C:\TEMP\testT.mat', 'testT');
fprintf(1, 'time: %s\n', datestr(now));

Sign in to comment.

Answers (1)

Chad Greene
Chad Greene on 21 Jul 2014
I've used dlmwrite for comma-delimited text files about this size, but I had trouble mixing numbers and strings. Using only numeric data, a single column of a million data points took about a minute to write. Can you write multiple text files--break it up by column or rows?

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!