Importing text files like above

Hi,
I am wondering how can I import the below text file data into a 5 x 2 table (NOT using the Import Data from toolbar)?
Symbol Description
0001.HK Cheung Kong (Holdings) Ltd
0002.HK CLP Holdings Ltd
0003.HK Hong Kong and China Gas Co. Ltd
0004.HK Wharf (Holdings) Ltd
Thx

1 件のコメント

Azzi Abdelmalek
Azzi Abdelmalek 2015 年 3 月 1 日
What will you put in the first column and in the second one?

サインインしてコメントする。

 採用された回答

dpb
dpb 2015 年 3 月 1 日

0 投票

data=char(textread('kin.txt','%s','delimiter','\n','whitespace','','headerlines',1));
data=table(data(:,1:7), data(:,9:end));
First read the file as a cell array (textread) and cast to character array (char())
Then put the two fixed-length pieces into the table (presuming it is a Matlab table datatype you're meaning by the use of table in the question).
Use your local file name of course, I just pasted the text for testing using that name here...

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeCell Arrays についてさらに検索

タグ

質問済み:

Kin
2015 年 3 月 1 日

コメント済み:

Kin
2015 年 3 月 2 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by