Faster Cell Array to CSV-file [more improved cell2csv.m]

バージョン 1.7.0 (2.65 KB) 作成者: gwoo
Writes cell array content into a *.csv file.
ダウンロード: 113
更新 2019/11/4

ライセンスの表示

First off, this an improvement on the code found here:
https://www.mathworks.com/matlabcentral/fileexchange/47055-cell-array-to-csv-file-improved-cell2csv-m

Credits to the original and previous authors for their work that this was built on.

This updated function:
- Improves performance when saving over network drives DRASTICALLY (by removing loop)
- Occasionally improves performance over local drive compared to previous cell2csv.m
- Improved performance over built-in writecell()
- Adds ability to set access permissions to output csv file (write, append, etc)
- Adds ability to set floating point precision (old cell2csv would typically limit at %.4f, and writecell is always %.15f)

Here are some timings I recorded on my computer:
% Input
>> x = [{'This', 'is', 'a', 'cell', 'time', 'test.'}; num2cell([(1:50000)', rand(50000,5)])];

On network:
% Compare to writecell
>> tic; cell2csv('new_cell2csv.csv', x, '%.15f'); toc
Elapsed time is 20.277467 seconds.
>> tic; writecell(x, 'writecell.csv'); toc
Elapsed time is 20.393940 seconds.

% Compare to old cell2csv
>> tic; cell2csv('new_cell2csv.csv', x); toc
Elapsed time is 19.339022 seconds.
>> tic; cell2csv('old_cell2csv.csv', x); toc
Elapsed time is 123.579863 seconds.

On local drive:
% Compare to writecell
>> tic; cell2csv('new_cell2csv.csv', x, '%.15f'); toc
Elapsed time is 18.165537 seconds.
>> tic; writecell(x, 'writecell.csv'); toc
Elapsed time is 21.017945 seconds.

% Compare to old cell2csv
>> tic; cell2csv('new_cell2csv.csv', x); toc
Elapsed time is 17.986039 seconds.
>> tic; cell2csv('old_cell2csv.csv', x); toc
Elapsed time is 14.386261 seconds.

Overall, it's a win!

引用

gwoo (2024). Faster Cell Array to CSV-file [more improved cell2csv.m] (https://www.mathworks.com/matlabcentral/fileexchange/73240-faster-cell-array-to-csv-file-more-improved-cell2csv-m), MATLAB Central File Exchange. 取得済み .

MATLAB リリースの互換性
作成: R2019b
すべてのリリースと互換性あり
プラットフォームの互換性
Windows macOS Linux
カテゴリ
Help Center および MATLAB AnswersPerformance and Memory についてさらに検索
タグ タグを追加
謝辞

ヒントを与えたファイル: fcell2csv - Fastest Cell Array to CSV-file

Community Treasure Hunt

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

Start Hunting!
バージョン 公開済み リリース ノート
1.7.0