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

Version 1.7.0 (2,65 ko) par gwoo
Writes cell array content into a *.csv file.
116 téléchargements
Mise à jour 4 nov. 2019

Afficher la licence

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!

Citation pour cette source

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. Extrait(e) le .

Compatibilité avec les versions de MATLAB
Créé avec R2019b
Compatible avec toutes les versions
Plateformes compatibles
Windows macOS Linux
Catégories
En savoir plus sur Performance and Memory dans Help Center et MATLAB Answers
Tags Ajouter des tags
Remerciements

A inspiré : 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!
Version Publié le Notes de version
1.7.0