Info
La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.
Sum up positions in columns located in sub-sub-folders in Excel
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Hello, I have a question regarding reading excel-data in subfolders. From the subfolders, which are containing excel files, I want to read specific positions in a column (named "2"). Later on, I want to sum this value and write them to another excel file, or similar.
The search path is as follows: Matlab_Esginatur (original folder with all files)=>Subfolder named "eltest" (in this subfolder I have a number of subfolders that are named based on different adresses) => Sub-sub-folder named as a specific adress that contains a number of excel-files from where I want to do the data extraction.
What I have managed so far is to read the different street names or folders. The code looks like follows:
path1 = 'Eltest'; subfolderInfo = dir(path1); subfolderNames = {subfolderInfo.name}; subfolderNames(ismember(subfolderNames,{'.','..'}))=[]; cd 'Eltest';
for fol_no=1:numel(subfolderNames) fileInfo = dir(subfolderNames{fol_no}); fileNames = {fileInfo.name}; fileNames(ismember(fileNames,{'.','..'}))=[]; fol_no for file_no = 1:numel(fileNames) file_no
ImportedData{fol_no,file_no} = readtable(char(fullfile(fileInfo(1).folder,fileNames(file_no)))); %ImportedData{fol_no,file_no} = readtable(char(fullfile(fileInfo(fol_no).folder,fileNames(file_no)))) end end total = table(ImportedData,'RowNames',subfolderNames)
The output reads:
total =
10×1 table ImportedData __________ Berzeliigatan 12 [1x14 cell] Berzeliigatan 14 [1x14 cell] Berzeliigatan 16 [1x14 cell] Berzeliigatan 18 [1x14 cell] Gråbrödragatan 10 [1x14 cell] Vasavägen 21 [1x14 cell] Vasavägen 23A [1x14 cell] Vasavägen 23B [1x14 cell] Vasavägen 25A [1x14 cell] Vasavägen 25B [1x14 cell]
How can I operate within each adress (that is including excel files) and sum the specific positions in the columns.
Thank you!
0 comentarios
Respuestas (0)
La pregunta está cerrada.
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!