将复杂的Excel或csv文件读入matlab
我有一个 Excel 文件,它是文本文件和数值的混合。 例如,文件如下所示,
25 file1
26 file2
这里 25 是第一个单元格(第 1 行,第 1 列)中的数值。 “file1”表示第二个单元格(行1,列2)中的内容。它可以是由多个段落组成的短文本文件。
我想将这个excel文件加载到matlab中,并将其存储为2*2矩阵。每个矩阵条目对应一个矩阵单元。
我尝试了 xlsread,但没有成功。我也尝试过textscan,但它似乎能够处理单元格只有字符串的情况。这里,一些单元格的内容本身就是文本文件。
I have an excel file, which is a mix of text file and numerical values.
For instance, the file look like this,
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您使用 XLSREAD 读取 Excel 文件,则可以使用第三个输出参数用于检索文本和数字数据(未处理)。
示例:
请注意,XLSREAD 仅限于 MS Excel 打开/读取文件的功能,因此某些特别大文件(根据我的经验超过 100 万行)将只能被部分读取。
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:
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.