txt2mat

버전 7.00 (32.9 KB) 작성자: Andres
fast and versatile ascii data import capable of handling large text files
다운로드 수: 16.4K
업데이트 날짜: 2021/10/25

라이선스 보기

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

인용 양식

Andres (2024). txt2mat (https://www.mathworks.com/matlabcentral/fileexchange/18430-txt2mat), MATLAB Central File Exchange. 검색됨 .

MATLAB 릴리스 호환 정보
개발 환경: R2021a
R2016b 이상 릴리스와 호환
플랫폼 호환성
Windows macOS Linux
카테고리
Help CenterMATLAB Answers에서 Low-Level File I/O에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!
버전 게시됨 릴리스 정보
7.00

· general compatibility with strings (string scalar as file name etc.)
· new read mode 'string'

6.60.3.0

more specific input argument checking for ReadMode (comment from T A) and NumericType

6.60.2.0

another fix for header line number bug and read mode "line"

6.60.1.0

fix for header line number bug reported by valere demeter

1.6.0.0

v06.60 · added option to select lines by line number ('SelectLineFun'), e.g. to skip every n-th line as suggested by Kaare · reduced memory footprint and improved speed during good/bad line filtering by working in chunks

1.5.0.0

v06.40 · better input argument check by inputparser, allowing input struct · minor changes in code and documentation

1.4.0.0

v06.17.3 · new read modes 'char' and 'cell' to provide txt2mat's preprocessing without numerical conversion · enable 'good line' filtering during file analysis · better version detection, (hopefully) suitable for MCR (thanks to Len for his remark)

1.3.0.0

v06.12 · added line filter as requested by Val Schmidt

1.2.0.0

v06.04 · better handling of replacement strings containing line breaks (initiated by DS) · allow '*' wildcard in file name

1.1.0.0

v06.01 · fixed bug: possible error message in file analysis when only header line number is given

1.0.0.0

v06.00 · introduction of read mode 'block' · 'MemPar' buffer value changed to scalar · reduced memory demand · modified help