using xlsread, i want to bifurcate data in different columns separated by commmas in each row of a excel sheet.
3 ビュー (過去 30 日間)
古いコメントを表示
I have a excel sheet containing author and their respective book titles separated by comma in each row. I want to separate the data as author column and title column using MATLAB. Can anybody help me please?
2 件のコメント
回答 (1 件)
Walter Roberson
2018 年 4 月 26 日
[~, txt, ~] = xlsread(...);
split_fields = regexp(txt(:,1), ',', 'split');
split_fields will now be a cell array containing as many entries as there were text lines in the first column. Each of the entries will be a cell array of character vectors. There will be a different number of character vectors for each original row.
You are going to have difficulty figuring out which of the portions mean on any one row. We can see from your samples that the patterns include:
- name, title, publisher, city
- name, title, edition, publisher
- name, title, city
- name, title, publisher
- name, name, title, publisher
The "name, title, city" line is arguably a "name, title, publisher" line, but there are multiple publishers in that city, with "Oxford University Press" only being the best known of them; we would have to assume that an abbreviated publisher name took precedence over a non-abbreviated city.
You got lucky in your samples that none of the titles happened to include commas: you should assume that in your larger dataset that commas in titles will occur.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Spreadsheets についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!