Unzip to a cell array, get the csv filles
3 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Stephen23
2025-3-11
编辑:Stephen23
2025-3-11
"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 个评论
更多回答(2 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Spreadsheets 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!