Code wont extract from file
Show older comments
Hi everyone,
Thanks for the help in advance...
My code wont find my file from its path and I cant find why. Im trying to create a loop which goes over a range of .csv files within their .zip folders within the location 'x' which I have hid. so it would be like x\1.zip\1.csv for the first loop, x\2.zip\2.csv for the second loop. my 'x' is copy and pasted straight from the finder.
clc;
clear all;
close all;
location = 'x'; % Set files location
combinedTable = [];
for i = 2017:2017
for j = 1:12
for k = 1:31
for l = 1:24
for m = 0:5
file = sprintf('PRT%d%02d%02d%02d%d000.zip', i, j, k, l, m);
dataFile = sprintf('%s.csv', file(1:end-4));
filePath = fullfile(location, file)
if exist(filePath, 'file') == 2
% File exists
T = readtable(filePath);
T = table2cell(T);
% Remove the first row of the table
T(1, :) = [];
% Concatenate the current table with the combined table
combinedTable = [combinedTable; T];
end
end
end
end
end
end
disp(combinedTable);
Answers (1)
Sulaymon Eshkabilov
on 28 Jun 2023
0 votes
Use unzip() while reading your data files, since your files are achived.
Categories
Find more on Downloads in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!