How to read a *.csv file where the numbers are in quotes ("1","2", ...)?

Hi,
I have a csv file where the numbers are in quotes (for whatever reason..):
"2.40000","0.16507","19.78564"
"2.50000","0.16671","20.64041"
"2.60000","0.16836","21.43273"
...
I'm desperately trying to read the numbers into a matrix, but all attempts (csvread, textscan, regexp, ...) failed. I'd therefore really appreciate any help on it. Thanks so much!

 Respuesta aceptada

[a,b,c]=xlsread(yourfile)
s=regexp(b,'[\d.]+','match')
out=str2double(cellfun(@(x) x{:},s,'un',0))

1 comentario

Jay Muller
Jay Muller el 28 de Jul. de 2015
Editada: Jay Muller el 28 de Jul. de 2015
Thanks SO much! The only thing I had to modify was the third line, as it only output one instead of the three columns.

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Preguntada:

el 27 de Jul. de 2015

Editada:

el 28 de Jul. de 2015

Community Treasure Hunt

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

Start Hunting!

Translated by