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!

 Accepted Answer

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

1 Comment

Thanks SO much! The only thing I had to modify was the third line, as it only output one instead of the three columns.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!