Tuan Anh Tran
Tuan Anh Tran

Reputation: 7237

Read second column of csv

I have this CSV data file that looks like

a,b
1,2
3,4

data = readdlm("my/local/path", ',')

however, when I access data[1], I'm only getting a, I thought it supposes to be [a,b]? Doing things like data[1:2] gets me the first column only.

Any idea how can I access the second column?

Upvotes: 3

Views: 1258

Answers (1)

Reza Afzalan
Reza Afzalan

Reputation: 5746

From the docs for readdlm:

Read a matrix from the source where each line gives one row...

So use data[row,col] syntax to get each element

Upvotes: 3

Related Questions