0

I have five years enter image description here, i.e., 2016 - 2021. For each year, there are six months selected Nov- Apri. Inside the month folder, there are days folders in .csv format. Inside the .csv folder, there are 14 cities with data on the electrical load with 24 hours time frame.

My goal is to open each day from the month file. Then store the data that I am interested in.

I was able to do it for one year, one month one day and capture the element I am interested in N.Y.K 124 & north 124.

There is a possible way to do it manually and enter each day's file. I wonder if I can optimize the code somehow and run all the files.

I attached the code I used. data inside the .csv file

days .csv files inside the month folder

months folder inside the year folder

    
path(path , 'C:\Users\okand\Desktop\Homework 1\Data\Nov2016_April_2017\20170401damlbmp_zone_CSV')

%% 2016 Nov 
Data_table = readtable('20170430damlbmp_zone.csv')
Data = readmatrix('20170430damlbmp_zone.csv')
% take the N.Y.K and North inromation from the loaded files
for i = 10 : 15 : 360
N_Y_K (i)=  Data(i,3);
x= i+1;
North(x) = Data(x,3);
end
N_Y_K = nonzeros (N_Y_K);
N_Y_K = transpose(N_Y_K)
North = nonzeros (North);
North = transpose(North)

  • Yes, you can do this. See the answer on the linked duplicate, the lower portion titled "Dynamic file naming". Basically, use a `dir()`, in your case 4 levels deep, then read the required CSV files, then store to whatever format you require. Given your description, a `struct` with fields for each city and arrays over time should work – Adriaan Jan 19 '22 at 09:00

0 Answers0