textscan in all columns for the first row

3 ビュー (過去 30 日間)
Rafael Freire
Rafael Freire 2018 年 11 月 23 日
編集済み: Cris LaPierre 2018 年 11 月 24 日
Hi,
I am having dificulties to read (load) a single row of a random size file. Please, how can I do it?
For ie. I would like to read all colums for the fisrt row of a csv file and create a string vector.
Thank you very much
Best Regards
Rafael
  2 件のコメント
Adam Danz
Adam Danz 2018 年 11 月 23 日
What difficulties are you having? What have you tried and why isn't it working?
Rafael Freire
Rafael Freire 2018 年 11 月 23 日
Basically, I don't know how to do it...

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

採用された回答

Cris LaPierre
Cris LaPierre 2018 年 11 月 23 日
Try fgetl. That's exactly what it does.
  3 件のコメント
Rafael Freire
Rafael Freire 2018 年 11 月 24 日
Hi,
Let's suppouse that we want the seccond or the n row of the file. How we can use this function?
Cris LaPierre
Cris LaPierre 2018 年 11 月 24 日
編集済み: Cris LaPierre 2018 年 11 月 24 日
You would use a while loop to continue reading in the data a line at a time until you got to the end of file (feof).
while ~feof(fid)
tline = fgetl(fid);
disp(tline)
end
You would want to process each line and assign your data to a variable using indexing so as not to overwrite the previously saved values.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLarge Files and Big Data についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by