I am reading csv files with the following format:
Header:,Date,Time,"MC2_Y241_TightnessPressValve","MC2_Y243_PressingValve""
Data,2015-09-16,15:41:52;781,"780.000000","0.0034"
Data,2015-09-16,15:41:52;791,"790.000000","0.1255"
Data,2015-09-16,15:41:52;801,"800.000000","1.5123"
Atm I am using fgetl(fid) to find the headers and all the dates and times. Then I use the knowledge of which rows and columns are containing doubles, to be able to use csvread() for fast reading. However, to use csvread(), I must first remove the quotes. I am currently doing this with a powershell script within matlab but it is too time consuming as I will need to read files of +200Mb.
Note: textscan with '%q' cannot be used for two reasons: 1) I want all doubles to be read as doubles immediately (converting is too time consuming). 2) The files contain various numbers of rows and columns.
This is for a standalone application.
I truly appreciate all help, I have spent countless hours on making this efficient.
f = fopen(file,'r'); h = f.getl(f);, split by delimitercols = regexp(h, ',', 'split');, then you get a cell string array containing the name of each column. you can know the number of column byncol = length(cols);From the value of each item ofcols, you can know what this column is as well as the datatype. then you can construct a format string according that. - Lees = fileread(you_file);then usetextscan(s, format). if the quote is a trouble, uses = strrep(s,'"','')to remove the quotes. - Leetextscan, especially theformatSpecpart - Lee