Unzip to a cell array, get the csv filles
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
HI I unzip a file to a cell
unzipfile =
10×1 cell array
{'2025-01-28/' }
{'2025-01-28/KBIS_V06_20250128_000621.csv'}
{'2025-01-28/KBIS_V06_20250128_001320.csv'}
{'2025-01-28/KBIS_V06_20250128_002007.csv'}
{'2025-01-28/KBIS_V06_20250128_002713.csv'}
{'2025-01-28/KBIS_V06_20250128_003412.csv'}
{'2025-01-28/KBIS_V06_20250128_004111.csv'}
{'2025-01-28/KBIS_V06_20250128_004816.csv'}
{'2025-01-28/KBIS_V06_20250128_005509.csv'}
{'2025-01-28/KBIS_V06_20250128_010208.csv'}
}
How can I get the content of the csv files? I woul like to avoid use unzip command to a folder I need a fast solution becaus I have lots of zip files containing hundrets of csv.
0 commentaires
Réponse acceptée
Stephen23
le 11 Mar 2025
Modifié(e) : Stephen23
le 11 Mar 2025
"I got Error using readtable Unable to find or open '2025-01-28/'. Check the path and filename or file permissions."
You get an error because a folder is not a file, yet you are trying to call FOPEN/READTABLE on a folder (the CSV files are stored in a folder, which UNZIP returns as the first element of the output cell array). Use ISFILE or similar to ignore any folders:
P = './mysub'; % absolute/relative path to where the files are unzipped to
C = unzip('2025-03-11.zip',P) % note the first element is NOT a filename!
dir(C{1})
C(~cellfun(@isfile,C)) = []; % remove folder names
D = C;
for k = 1:numel(C)
F = C{k};
T = readtable(F);
D{k} = T;
end
All of the imported data is in the cell array D
D{:}
vertcat(D{:})
Depending on the existence of other files, you might also be able to use DIR.
0 commentaires
Plus de réponses (2)
Voir également
Catégories
En savoir plus sur Spreadsheets dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!