フィルターのクリア

How to read/load text file without header?

25 ビュー (過去 30 日間)
Sohel Rana
Sohel Rana 2023 年 7 月 25 日
コメント済み: Voss 2023 年 7 月 26 日
Hello,
I have a text file (attached here) which contains headers. How can I read/load just numeric data from the text file? In the attached file, for example, how can I get all data for column wav1-1 or wav1-2, etc?
Thank you!

採用された回答

Voss
Voss 2023 年 7 月 25 日
readtable seems to work well on this file.
t = readtable('Test Data.txt');
Warning: Column headers from the file were modified to make them valid MATLAB identifiers before creating variable names for the table. The original column headers are saved in the VariableDescriptions property.
Set 'VariableNamingRule' to 'preserve' to use the original column headers as table variable names.
head(t) % check the first 10 rows -> looks ok
Date Time LineNumber SystemStatus Wav1_1 Wav1_2 Wav1_3 Wav1_4 Wav1_5 Wav1_6 Wav1_7 Wav1_8 Wav1_9 Wav1_10 Wav1_11 Wav1_12 Pow1_1 Pow1_2 Pow1_3 Pow1_4 Pow1_5 Pow1_6 Pow1_7 Pow1_8 Pow1_9 Pow1_10 Pow1_11 Pow1_12 ______________ ________ __________ ____________ ______ ______ ______ ______ ______ ______ ______ ______ ______ _______ _______ _______ ______ ______ ______ ______ ______ ______ ______ ______ ______ _______ _______ _______ {'2023/07/25'} 13:30:05 17892 {'0 0 0 0'} 1522.2 1526.2 1530.2 1534.2 1537.1 1542.2 1546.1 1550.2 1554.1 1558.1 1561.4 1566.1 29.1 29.2 29 28.4 35.6 36.9 38.1 42.3 41.4 43.6 38 39.8 {'2023/07/25'} 13:30:06 17893 {'0 0 0 0'} 1522.2 1526.2 1530.2 1534.2 1537.1 1542.2 1546.1 1550.2 1554.1 1558.1 1561.4 1566.1 29.1 29.3 29.1 28.3 35.6 36.9 38 42.3 41.4 43.5 38 39.8 {'2023/07/25'} 13:30:07 17894 {'0 0 0 0'} 1522.2 1526.2 1530.2 1534.2 1537.1 1542.2 1546.1 1550.2 1554.1 1558.1 1561.4 1566.1 29.1 29.2 29.1 28.4 35.6 36.8 38 42.4 41.4 43.5 38 39.7 {'2023/07/25'} 13:30:08 17895 {'0 0 0 0'} 1522.2 1526.2 1530.2 1534.2 1537.1 1542.2 1546.1 1550.2 1554.1 1558.1 1561.4 1566.1 29.1 29.3 29.1 28.4 35.6 36.8 38 42.4 41.4 43.6 38 39.7 {'2023/07/25'} 13:30:09 17896 {'0 0 0 0'} 1522.2 1526.2 1530.2 1534.2 1537.1 1542.2 1546.1 1550.2 1554.1 1558.1 1561.4 1566.1 29.1 29.3 29.1 28.4 35.6 36.8 38.1 42.4 41.4 43.6 38 39.8 {'2023/07/25'} 13:30:10 17897 {'0 0 0 0'} 1522.2 1526.2 1530.2 1534.2 1537.1 1542.2 1546.1 1550.2 1554.1 1558.1 1561.4 1566.1 29.1 29.3 29.1 28.4 35.7 36.9 38.1 42.4 41.4 43.4 38 39.7 {'2023/07/25'} 13:30:11 17898 {'0 0 0 0'} 1522.2 1526.2 1530.2 1534.2 1537.1 1542.2 1546.1 1550.2 1554.1 1558.1 1561.4 1566.1 29.1 29.2 29.1 28.3 35.6 36.9 38.1 42.2 41.4 43.5 37.9 39.7 {'2023/07/25'} 13:30:12 17899 {'0 0 0 0'} 1522.2 1526.2 1530.2 1534.2 1537.1 1542.2 1546.1 1550.2 1554.1 1558.1 1561.4 1566.1 29.1 29.3 29.1 28.4 35.6 36.8 38.1 42.3 41.4 43.6 38.1 39.7
% access Wav1-1 column:
t.Wav1_1
ans = 598×1
1.0e+03 * 1.5222 1.5222 1.5222 1.5222 1.5222 1.5222 1.5222 1.5222 1.5222 1.5222
% access Wav1-2 column:
t.Wav1_2
ans = 598×1
1.0e+03 * 1.5262 1.5262 1.5262 1.5262 1.5262 1.5262 1.5262 1.5262 1.5262 1.5262
  2 件のコメント
Sohel Rana
Sohel Rana 2023 年 7 月 26 日
This is great! Works well.Thank you for your answer.
Voss
Voss 2023 年 7 月 26 日
You're welcome!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeText Files についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by