fcell2csv - Fastest Cell Array to CSV-file
Version 1.1.0 (6,43 KB) von
wfH
writes nD cell array into a ASCII delimited file (e.g., *.csv) using c-mex.
I've found a series of functions (`cell2csv`) that writes cell array content in to a *.csv file.
All of these functions is inefficient to handle a large cell array (number of nows > 20000), and none can handle a nD cell array.
So, I created this function fcell2csv that adopts c-mex file to improve performance.
`fcell2csv` is about 40~90 times faster than the codes found in FEX !
NOTE!
The c-mex file is necessary.
Run the following code to compile.
mex cell2csv_mex.c -R2018a -O
Run the following code for comparison.
x = [{'This', 'is', 'a', 'cell', 'time', 'test.'}; num2cell([(1:50000)', rand(50000,5)])];
% Compare to built-in `writecell`/ `cell2csv`
tic; writecell(x, 'writecell.csv'); t1 = toc
tic; cell2csv('cell2csv.csv', x); t2 = toc % removing loop % https://www.mathworks.com/matlabcentral/fileexchange/73240-faster-cell-array-to-csv-file-more-improved-cell2csv-m
tic; cell2csv('cell2csv.csv', x); t3 = toc % https://www.mathworks.com/matlabcentral/fileexchange/47055-cell-array-to-csv-file-improved-cell2csv-m
tic; fcell2csv('fcell2csv.csv', x); t4 = toc % my c-mex
On my notebook (i7-8550u)
t1~33.127151 seconds
t2~8.365726 seconds
t3~11.168033 seconds
t4~0.513955 seconds
WIN!!
Zitieren als
wfH (2026). fcell2csv - Fastest Cell Array to CSV-file (https://de.mathworks.com/matlabcentral/fileexchange/102870-fcell2csv-fastest-cell-array-to-csv-file), MATLAB Central File Exchange. Abgerufen.
Kompatibilität der MATLAB-Version
Erstellt mit
R2021b
Kompatibel mit R2018a und späteren Versionen
Plattform-Kompatibilität
Windows macOS LinuxTags
Quellenangaben
Inspiriert von: mex_WriteMatrix, Faster Cell Array to CSV-file [more improved cell2csv.m], Cell Array to CSV-file [improved cell2csv.m]
Live Editor erkunden
Erstellen Sie Skripte mit Code, Ausgabe und formatiertem Text in einem einzigen ausführbaren Dokument.
| Version | Veröffentlicht | Versionshinweise | |
|---|---|---|---|
| 1.1.0 | feat: flexible input arguments
|
||
| 1.0.0 |
