matlab - Import csv file with values within quotation marks -


i want import csv file (data.csv) structured follows

area,mtu,biomass mw,lignite mw cta|de(50hertz),"01.01.2015 00:00 - 01.01.2015 00:15 (cet)","1227","6485" cta|de(50hertz),"01.01.2015 00:15 - 01.01.2015 00:30 (cet)","","6421" cta|de(50hertz),"01.01.2015 00:30 - 01.01.2015 00:45 (cet)","1230","n/e" cta|de(50hertz),"01.01.2015 00:45 - 01.01.2015 01:00 (cet)","n/a","6299" 

i've tried use textscan works pretty well, process stops once empty quotation marks reached. argument 'emptyvalue',0 not work.

file = fopen('data.csv'); data = textscan(file, '%q %q "%f" "%f"', 'delimiter', ',',...     'headerlines', 1,'treatasempty', {'n/a', 'n/e'}, 'emptyvalue',0); fclose(file); 

any idea, on how import whole file.

textscan(file,'%q%q%q%q%[^\n\r]','delimiter',',','headerlines',1); 

worked fine me. values like: "01.01.2015 00:00 - 01.01.2015 00:15 (cet)" trivial write separate parser for. don't try in 1 step. cause pain , suffering. break simple single steps.

also, highly recommend right clicking file in "current folder" window in matlab, selecting "import data" makes importing csv (or tab separated, or fixed width data files) trivial.


Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -

Python Pig Latin Translator -