How can I extract certain rows from a CSV imported table?
Mostrar comentarios más antiguos
I have imported CSV file into MATLAB
T = readtable('Historia_Rachunku.csv')
Extracted relevant part of it:
variablesByName = T(1:end,["Odbiorca","Data Księgowania","Kwota",])

And now I'd like to extract transactions belonging to single company. I tried this:
rowsByName = T(["PAYPRO S.A."],:)
But I get an error. How can I extract transactions based on their companies (ex. BILETY, PAYPRO, ZABKA) and then put them into separate tables?
Respuesta aceptada
Más respuestas (1)
Walter Roberson
el 4 de Sept. de 2022
In order for you to be able to do that using the syntax you tried, you would have needed to have told MATLAB that table() T should have 'RowNames', with the data giving by the Odbiorca column.
However, 'RowNames' must be unique, and it is not clear that your entries are unique. Your entries are not unique to the number of characters that we can see.
What you can do is
G = findgroups(T.Odbiorca);
grouped_tables = splitapply(@(varargin) {table(varargin{:}, 'VariableNames', T.Properties.VariableNames)}, T, G);
grouped_tables is now a cell array of tables, in which each table only has entries for a single company.
1 comentario
KarolN
el 5 de Sept. de 2022
Categorías
Más información sobre Tables en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!