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

2 次查看(过去 30 天)
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 个评论
Ivan
Ivan 2014-7-21
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));

请先登录,再进行评论。

回答(1 个)

Chad Greene
Chad Greene 2014-7-21
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?

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by