How to read RANDOM rows using DataStore
Afficher commentaires plus anciens
ds = datastore('file_name.csv',... 'TreatAsMissing','NA', 'NumHeaderLines',1,'ReadVariableNames',false)
ds.MissingValue =0;
ds.ReadSize = 20000; % this will read sequential rows, I need to read random rows
Réponses (1)
Rijuta
le 22 Déc 2023
0 votes
Hi Mujahid,
I understand that you want to read random rows from a datastore in MATLAB.
Please follow the steps below:
- Create a datastore object that points to your data source using the 'datastore' function.
- Determine the number of rows in the datastore using the 'size' function.
- Generate random indices corresponding to the rows you want to read using the 'randperm' function.
- You can now use the 'read' function to read in the data, or 'readall' if you need to load all data into memory first.
Follow the documentation below to get a detailed description of the functions used:
- 'datastore' function: https://www.mathworks.com/help/matlab/datastore.html
- 'randperm' function: https://www.mathworks.com/help/matlab/ref/randperm.html
- 'read' function: https://www.mathworks.com/help/matlab/ref/matlab.io.datastore.read.html
- 'readall' function: https://www.mathworks.com/help/matlab/ref/matlab.io.datastore.readall.html
I hope the above steps help you read random rows from a datastore.
Catégories
En savoir plus sur Descriptive Statistics and Insights dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!