faster reading using csvread question

2 views (last 30 days)
colors
colors on 22 May 2017
Answered: Matthew Eicholtz on 22 May 2017
I have a csv file that looks like the below
_TYPE_ _NAME_ a b c d date
CRR a 1 0.778220822 0.711397234 0.29490149 4/30/2017
CRR b 1 0.778220822 0.711397234 0.29490149 4/30/2017
CRR d 1 0.778220822 0.711397234 0.29490149 4/30/2017
CRR e 1 0.778220822 0.711397234 0.29490149 4/30/2017
I would like to store the numeric values column a-d as a matrix the date column as a separte variable in form of a vector the name column as a separate variable in form of a vector.
the number of numeric columns can differ in this above example it is only 4 , but you can have varying number of columns, the last column is always the date and the first two columns are always type and name
I have been using xlsread for this but was wondering if there is a faster way using csvread or some other function
many thanks for your help

Answers (1)

Matthew Eicholtz
Matthew Eicholtz on 22 May 2017
Have you tried readtable? I haven't run any timing diagnostics to see which is faster, but that could be another option for you to try.
Here's an example function call:
T = readtable(filename,'Delimiter',',','ReadVariableNames',true);

Categories

Find more on Dates and Time in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by