readfile

버전 4.1.1.0 (39.4 KB) 작성자: Rik
read any (text) file, either UTF8 or ANSI
다운로드 수: 565
업데이트 날짜: 2023/1/19

View readfile on File Exchange

If you want to read a (text) file with Matlab, you need to know what encoding it is: UTF-8 (the 'modern' standard) or ANSI (US-ASCII, the 'old' standard). If you have files you want to read automatically, where you don't necessarily know the encoding you would have to guess. This will sometimes result in strange text that you only notice 3 or 4 steps later.

This function takes care of that problem by providing a single way of reading a file. It preserves leading and trailing spaces, it preserves empty lines, and it can handle both UTF-8 files and ANSI files. Note that although the encoding should be specified in a special leading bit, it is not possible to read this with Matlab nor is it actually guaranteed to be present. It is therefore possible that a file is read with the wrong encoding, although this should be a very rare occurrence.

It is also possible to enter the file name as a URL. In that case this function will download the file to the temporary directory, read it, and delete it. If that fails, webread/urlread will be used to read the file as a char array, although that may limit which characters can be read depending on the Matlab/Octave release and OS.

This function support most syntax options that the readlines function (introduced in R2020b) supports. It even has a switch to reproduce a bug with reading most emoji. In general cellstr(readlines(___)) should provide equivalent results.

Licence: CC by-nc-sa 4.0

인용 양식

Rik (2024). readfile (https://github.com/thrynae/readfile/releases/tag/v4.1.1), GitHub. 검색됨 .

MATLAB 릴리스 호환 정보
개발 환경: R2022b
R13SP1 이상 릴리스와 호환
플랫폼 호환성
Windows macOS Linux
카테고리
Help CenterMATLAB Answers에서 Text Files에 대해 자세히 알아보기

Community Treasure Hunt

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

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

See release notes for this release on GitHub: https://github.com/thrynae/readfile/releases/tag/v4.1.1

4.1.0.0

See release notes for this release on GitHub: https://github.com/thrynae/readfile/releases/tag/v4.1.0

4.0.0.1

See release notes for this release on GitHub: https://github.com/thrynae/readfile/releases/tag/v4.0.0.1

4.0.0

See release notes for this release on GitHub: https://github.com/thrynae/readfile/releases/tag/v4.0.0

3.0.0

See release notes for this release on GitHub: https://github.com/thrynae/readfile/releases/tag/v3.0.0

2.0.2

See release notes for this release on GitHub: https://github.com/thrynae/readfile/releases/tag/v2.0.2

2.0.1

See release notes for this release on GitHub: https://github.com/thrynae/readfile/releases/tag/2.0.1

2.0

See release notes for this release on GitHub: https://github.com/thrynae/readfile/releases/tag/2.0

1.0.2

Adapted subfunction and updated MacOS Siera to Catalina. The function now also warns on Octave for chars >255.

1.0.1

cosmetics and expanded test

1.0.0

이 GitHub 애드온의 문제를 보거나 보고하려면 GitHub 리포지토리로 가십시오.
이 GitHub 애드온의 문제를 보거나 보고하려면 GitHub 리포지토리로 가십시오.