How could I read a single cell of an .csv file using readmatrix function with import options?

23 ビュー (過去 30 日間)
Hello to everyone, I need to process different data from a .csv file. I do ask for the user what are the row ranges that need to read the code, with that, I need to save a value from a particular cell from the spreadsheet.
Next work very well for me. But I would like to know if it's possible to make this using import options.
kappa = readmatrix('1_5B_2.csv', 'Range', 'D6:D6');
Thanks in advance.
  2 件のコメント
dpb
dpb 2020 年 8 月 6 日
"possible to make this using import options."
Not sure what you mean here...explain more in detail.
Sudheer Bhimireddy
Sudheer Bhimireddy 2020 年 8 月 6 日
Try this link to know the what import options you have for the file being read.
Then you can use either readtable to readmatrix with possible import options.

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

採用された回答

Omar Andrés Rosada González
Omar Andrés Rosada González 2020 年 8 月 6 日
Thank you, it was a pretty simple solution.
First I did use detectImportOptions, searching the variable name (column), then I defined the data line range (row). In my case, it would be only using the same row position on both sides. Something like the next code.
opts = detectImportOptions('1_5B_2.csv');
opts.SelectedVariableNames = ('Var4');
opts.DataLines = [range(1,1) range(1,1)];
kappa = readmatrix('1_5B_2.csv', opts);

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeData Import and Analysis についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by