Code wont extract from file

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
Sulaymon Eshkabilov on 28 Jun 2023
Use unzip() while reading your data files, since your files are achived.

2 Comments

Is there a way I can do this without unzipping as its hundreds of thousands of files?
Also, permission is denied to do this (altough I do have access to the folder I think its read only)

Sign in to comment.

Categories

Products

Release

R2020b

Asked:

on 28 Jun 2023

Commented:

on 28 Jun 2023

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!