MATLAB Answers

How to import data from .csv file, from specific columns of a row, into an array

17 views (last 30 days)
Anaya Kharwadkar
Anaya Kharwadkar on 15 Sep 2020
Edited: Vasishta Bhargava on 16 Sep 2020
I want to import data from one row of a .csv file into an array. But, I do not want all columns in the array. I want columns E through to the end of row 263 in my array.
I tried the following code:
GDPperCapita = importdata('GDP.csv')
array = GDPperCapita(261,5:end)
but I am getting an empty cell array: (Output)
array =
1×0 empty cell array
I have attached an image to give a clear idea of the cells I want in my array:

Answers (1)

Vasishta Bhargava
Vasishta Bhargava on 16 Sep 2020
Edited: Vasishta Bhargava on 16 Sep 2020
% if true
% code
% end
GDPperCapita = importdata('GDP.csv')
array = GDPperCapita(263,5:end)
The highlighted box array is row 263 in excel file and corresponds to world. But you are importing the row 261 in your code which is empty in your excel file and corresponds to Vietnam

  0 Comments

Sign in to comment.

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by