MATLAB: How to read data from csv files containing both text and data

csvreadText Analytics Toolboxtextscan

I tried to use csvread but from the forum, it seems that I should use textscan to read the values when there is also text in the csv file: However, I don't understand what to put in argument of the function, especially when it comes to specifiers. I would like to have a matrix with my data. The .csv file is attached.
This is what I have tried so far. M = textscan('test.csv','%s %s %s %s')
I work on MATLAB 2014a

Best Answer

'Pends on what you mean, specifically, by 'data'. One of the easiest ways to treat mixed data files if you do want the numeric and text portions separately is xlsread; it will autogmagically return the text, numeric and then the 'raw' data as a cell array...

>> [n,t,r]=xlsread('test.csv')
n =
     1     1     1
     2     2     2
     3     3     3
     4     4     4
     5     5     5
     6     6     6
     7     7     7
     8     8     8
     9     9     9
    10    10    10
    11    11    11
t =
  15×4 cell array
    'text'    'text'    'text'    'text'
    'text'    'text'    'text'    'text'
    ''        ''        ''        'text'
    ''        ''        ''        'text'
    ''        ''        ''        'text'
    ''        ''        ''        'text'
    ''        ''        ''        'text'
    ''        ''        ''        'text'
    ''        ''        ''        'text'
    ''        ''        ''        'text'
    ''        ''        ''        'text'
    ''        ''        ''        'text'
    ''        ''        ''        'text'
    'text'    'text'    'text'    'text'
    'text'    'text'    'text'    'text'
r =
  15×4 cell array
    'text'    'text'    'text'    'text'
    'text'    'text'    'text'    'text'
    [   1]    [   1]    [   1]    'text'
    [   2]    [   2]    [   2]    'text'
    [   3]    [   3]    [   3]    'text'
    [   4]    [   4]    [   4]    'text'
    [   5]    [   5]    [   5]    'text'
    [   6]    [   6]    [   6]    'text'
    [   7]    [   7]    [   7]    'text'
    [   8]    [   8]    [   8]    'text'
    [   9]    [   9]    [   9]    'text'
    [  10]    [  10]    [  10]    'text'
    [  11]    [  11]    [  11]    'text'
    'text'    'text'    'text'    'text'
    'text'    'text'    'text'    'text'
>> 

readtable is also useful; it will bring in all the data as columnar but will be cell array since each column is a mixture.

Truthfully, depending upon what it is that is to be done, it might realistically be the best thing to reorganize the file structure and "fix" the problem at that point.