image thumbnail

txt2mat

versión 7.00 (32.9 KB) por Andres
fast and versatile ascii data import capable of handling large text files

16,1K descargas

Actualizada 25 Oct 2021

Ver licencia

As txt2mat basically is a wrapper for sscanf, it quickly converts ascii files containing m-by-n numeric data, allowing for header lines. When encountering rows with different numbers of data elements, it will work line-by-line and thus slow down somewhat.
You may let txtmat carry out an automatic data layout analysis on comparatively 'simple' text files (header lines + decimal number data with common delimiters). By this analysis it is able to directly import most numeric .csv-files, for instance.
As txt2mat can perform string and regular expression replacements before the numeric conversion, it can cope with many irregularities within the data. By that it is also capable of detecting and handling commas as decimal characters (common german notation).
You can filter lines by keywords, skip lines by line number, provide appropriate format strings (as for sscanf), or split up the import process for huge files if you encounter memory problems.
You may also use the above to simply read the manipulated text into a character vector or to put each line into a separate cell or string vector element without the numeric conversion.
txt2mat should work on Matlab R2016b and newer versions.
Comments and suggestions welcome.
Andres

Citar como

Andres (2022). txt2mat (https://www.mathworks.com/matlabcentral/fileexchange/18430-txt2mat), MATLAB Central File Exchange. Recuperado .

Compatibilidad con la versión de MATLAB
Se creó con R2021a
Compatible con la versión R2016b y siguientes
Compatibilidad con las plataformas
Windows macOS Linux

Community Treasure Hunt

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

Start Hunting!