Borrar filtros
Borrar filtros

string inside a table

2 visualizaciones (últimos 30 días)
eric capnu
eric capnu el 20 de Sept. de 2017
Respondida: Jeremy Hughes el 21 de Sept. de 2017
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 comentarios
Walter Roberson
Walter Roberson el 20 de Sept. de 2017
Is it possible that the original data contained "- 20" with a space between the "-" and the "20" ?
eric capnu
eric capnu el 20 de Sept. de 2017
NaN would be a nice choose. And no, it is just '-'.

Iniciar sesión para comentar.

Respuesta aceptada

Walter Roberson
Walter Roberson el 20 de Sept. de 2017
YourTable.column1 = str2double(YourTable.column1);

Más respuestas (1)

Jeremy Hughes
Jeremy Hughes el 21 de Sept. de 2017
Try:
>> T = readtable(filename,'TreatAsEmpty',{'-'})
Jeremy

Categorías

Más información sobre Tables en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by