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

10 vues (au cours des 30 derniers jours)
Jay Muller
Jay Muller le 27 Juil 2015
Modifié(e) : Jay Muller le 28 Juil 2015
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!

Réponse acceptée

Azzi Abdelmalek
Azzi Abdelmalek le 27 Juil 2015
[a,b,c]=xlsread(yourfile)
s=regexp(b,'[\d.]+','match')
out=str2double(cellfun(@(x) x{:},s,'un',0))
  1 commentaire
Jay Muller
Jay Muller le 28 Juil 2015
Modifié(e) : Jay Muller le 28 Juil 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.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Variables dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by