ReadSize property for the datastore
7 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I use datastore to store tabular text file. I know number of rows in the file and want to pre-estimate number of reads with the read function. Matlab Help says
If ReadSize is a positive integer, then each call to read reads at most ReadSize rows.
When the number of rows in the file is 50000 and the ReadSize property is set to 20000 I expect the number of reads will be 3 (20000+20000+10000), but it can be 4 or more. It doesn't contradict the fact that the ReadSize is the upper limit, but anyway is there any possibilities to determine the number of blocks which will be read?
0 commentaires
Réponses (1)
Jayanti
le 19 Mar 2025
Hi Aleksey,
You can write a custom function or loop to simulate reads and calculate the number of reads it takes based on the data.
Set the “ReadSize” property and use a while loop to read data from the datastore until there is no more data. Subsequent calls to the read function continue reading from the endpoint of the previous call.
Please refer to the following code for better understanding:
ds = tabularTextDatastore ("file.csv","TreatAsMissing","NA","MissingValue",0);
ds.ReadSize = 200;
r=0;
while hasdata(ds)
T = read(ds);
r=r+1;
end
I am also attaching official MathWorks documentation link on “read” function for your reference:
0 commentaires
Voir également
Catégories
En savoir plus sur Datastore dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!