How to set an index on a table
Show older comments
I have an csv file and am reading it using readtable(). I want to set a index on this table for fast access of data (something similar to set_index in python(pandas)).
T=readtable('file.csv');
index1=find(T.column1==value1);
index2=find(T.column2==value2);
index=intersect(index1,index2);
sam=table2array(T(index,6));
I want to do this for different values of value1 and value2 (approx 12000 times). This is taking about 600 seconds for 12000 records. Is there a way to access the table fast?
Thanks in advance.
1 Comment
per isakson
on 2 Oct 2017
Edited: per isakson
on 2 Oct 2017
- If your file contains only numerical data, I think working with old time matrices rather than tables will make a significantly faster code.
Accepted Answer
More Answers (0)
Categories
Find more on Tables in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!