Unzip to a cell array, get the csv filles
조회 수: 1 (최근 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에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!