read file containing mixed content
古いコメントを表示
Hello,
The format of an input text file is the following:
1 23.08 был
2 367.92 сказал
3 12567.53 когда
...
and so on.
How to read this file so that the following loop can be used:
for i=1:length(file)
str=fileName(i,3);
...
end
Thanks.
9 件のコメント
b
2022 年 1 月 8 日
Rik
2022 年 1 月 8 日
I personally prefer to do the parsing myself if the automatic one-liner tools fail.
Have you tried reading it as text and doing the parsing with textscan?
b
2022 年 1 月 8 日
Rik
2022 年 1 月 8 日
Can you attach the file and post your code? That way we can experiment.
"How to read the last column?"
It works perfectly for me using R2021b (the current online version):
T = readtable('a.txt')
So whatever version or OS you are using is not up-to-date. This also means that the solution will depend on what version (and possibly OS) you are using, which you have not told us.
b
2022 年 1 月 9 日
Christopher Creutzig
2022 年 1 月 11 日
20a may need a hint as to the file encoding you are using. readtable("a.txt","Encoding","UTF-8","NumHeaderLines",0) seems to work for me.
b
2022 年 1 月 12 日
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Text Files についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!