Import CSV file with mixed data types

前端 未结 9 2208
眼角桃花
眼角桃花 2020-11-27 04:13

I\'m working with MATLAB for few days and I\'m having difficulties to import a CSV-file to a matrix.

My problem is that my CSV-file contains almost only Strings and

相关标签:
9条回答
  • 2020-11-27 05:15

    Use xlsread, it works just as well on .csv files as it does on .xls files. Specify that you want three outputs:

    [num char raw] = xlsread('your_filename.csv')
    

    and it will give you an array containing only the numeric data (num), an array containing only the character data (char) and an array that contains all data types in the same format as the .csv layout (raw).

    0 讨论(0)
  • 2020-11-27 05:15

    Depending on the format of your file, importdata might work.

    You can store Strings in a cell array. Type "doc cell" for more information.

    0 讨论(0)
  • 2020-11-27 05:16

    Have you tried to use the "CSVIMPORT" function found in the file exchange? I haven't tried it myself, but it claims to handle all combinations of text and numbers.

    http://www.mathworks.com/matlabcentral/fileexchange/23573-csvimport

    0 讨论(0)
提交回复
热议问题