フィルターのクリア

string inside a table

2 ビュー (過去 30 日間)
eric capnu
eric capnu 2017 年 9 月 20 日
回答済み: Jeremy Hughes 2017 年 9 月 21 日
hi guys:
i export csv files from an url by using urlwrite and readtable commands. the resulting table is (or should be) composed of numbers, somehow some table cells has the value '-'. Because of this, the whole column containing that string '-' become into string values, like this:
column1 column2
------- -------
'12' 34
'10' 12
'-' 20
'1.1' 13.1
'34.9' 66
is there a way to avoid it? i mean, the whole table as numbers...
thanks
  3 件のコメント
Walter Roberson
Walter Roberson 2017 年 9 月 20 日
Is it possible that the original data contained "- 20" with a space between the "-" and the "20" ?
eric capnu
eric capnu 2017 年 9 月 20 日
NaN would be a nice choose. And no, it is just '-'.

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

採用された回答

Walter Roberson
Walter Roberson 2017 年 9 月 20 日
YourTable.column1 = str2double(YourTable.column1);

その他の回答 (1 件)

Jeremy Hughes
Jeremy Hughes 2017 年 9 月 21 日
Try:
>> T = readtable(filename,'TreatAsEmpty',{'-'})
Jeremy

カテゴリ

Help Center および File ExchangeTables についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by