How to store the real row id in datastore?

1 visualización (últimos 30 días)
Ahmed Hamed
Ahmed Hamed el 30 de Abr. de 2016
Respondida: Naga el 26 de Nov. de 2024
I'have a file named 'HIS_all.csv' and i used datastore function to store it as follows
ds = datastore('HIS_all.csv', 'DatastoreType', 'tabulartext', 'TreatAsMissing', 'NA');
datastore by default makes cell array named VariableNames containing the variable names. Is there any way to do this with rows. i.e. i need to make a unique id for each row that will be passed with it to the map function to make something like this
addmulti(intermidiateValuesOut,key,{ind});
I'd like the key here to be the real id in the file. for example if I'm working with row number 10000, I'd like the key to be 10000. Is this possible?
Please Help Thanks in advance

Respuestas (1)

Naga
Naga el 26 de Nov. de 2024
Hello Ahmed,
When using the 'datastore' function in MATLAB to read a CSV file, you can access each row sequentially. However, there isn't a built-in feature that provides a unique identifier for each row corresponding to its line number in the file. To create such an identifier, you can manually track the row index while processing the data. Begin by loading the data with the 'datastore' function as you normally would. Then, initialize a counter to keep track of the row indices. As you read each data chunk from the datastore, append these row indices to the data.

Categorías

Más información sobre Big Data Processing en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by