headcount(file_name​, header_mark)

版本 1.0.0.1 (1.8 KB) 作者: Naor Movshovitz
Return number of header lines in text file.
132.0 次下载
更新时间 2019/4/16

查看许可证

Many file-reading functions allow the user to specify a number of header lines to skip before reading in data. To facilitate reading from files with an unknown or varying number of header lines, this function opens a text file, counts the number of lines in the header block (defined by a header mark; default is '#''), and (always!) closes the file. This makes it easy to read in data with a single call.
For example:
raw = importdata(my_csv_file, ',', headcount(my_csv_file, '%'));
reads a csv table, automatically skipping lines starting with '%' in the beginning of the file. (Note: it is true that importdata(my_file) will try to infer delimiters and headers automatically, but it will often fail.)

引用格式

Naor Movshovitz (2024). headcount(file_name, header_mark) (https://www.mathworks.com/matlabcentral/fileexchange/48481-headcount-file_name-header_mark), MATLAB Central File Exchange. 检索时间: .

MATLAB 版本兼容性
创建方式 R2011b
兼容任何版本
平台兼容性
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!
版本 已发布 发行说明
1.0.0.1

Allowing leading white space in header lines, before header mark

1.0.0.0