开发者

read complicated excel or csv file into matlab

I have an excel file, which is a mix of text file and numerical values. For instance, the file look like this,

开发者_如何学C
25  file1
26  file2

Here the 25 is an numerical value in the first cell (row 1, column1). "file1" represents the content in the second cell(row1, column2). It can be short text file composed of multiple paragraphs.

I want to load this excel file into matlab, and store it into a 2*2 matrix. Each matrix entry corresponds to a matrix cell.

I tried xlsread, but it did not work. I also tried textscan, but it seems to be able to handle the scenario where a cell has a string only. Here, the contents of some cells are text files itself.


If you are reading an Excel file using XLSREAD, you can use the third output argument to retrieve the both the textual and numeric data (unprocessed).

Example:

read complicated excel or csv file into matlab

>> [~,~,raw] = xlsread('Book1.xls')
raw = 
    [25]    'hello world.'
    [26]       [1x38 char]

>> raw{2,2}
ans =
this is an example
of multi-line
text

Note that XLSREAD is limited to the capabilities of MS Excel to open/read files, so some especially large files (in my experience 1 million+ rows) will get only partially read.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜