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!

 Akzeptierte Antwort

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

1 Kommentar

Jay Muller
Jay Muller am 28 Jul. 2015
Bearbeitet: Jay Muller am 28 Jul. 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.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by