How to extract the column_13 from 79 csv files and save into the new csv file

3 views (last 30 days)
Hi,
How to extract the column_13 from 79 csv files and save it in a separate csv file so the new csv file will have 79 column of column_13 from each file. I am able to read column_13 from one file but not sure how to extract from all the files and save it in a separate file.
Code Tried so far:
dataFolder = 'F:\3-PIV_Experimental_Data\Calculations_TurbulentIntensity\line_Data\Elliptical_Side_LSB\Length\DesignPoint\110_outlet';
list = dir(fullfile(P,'*.csv'));
for kk = 1:numel(list)
data = readtable(...
fullfile(list(kk).folder, list(kk).name));
extract = (data{:,13});
end

Accepted Answer

Geoff Hayes
Geoff Hayes on 17 Jun 2022
@muhammad choudhry - create a cell array to store the 13th column from each file. For example,
extractedData = cell(numel(list),1);
for kk = 1:numel(list)
data = readtable(...
fullfile(list(kk).folder, list(kk).name));
extractedData{kk} = data{:,13};
end
Then you should be able to save the extractedData to your new file.

More Answers (0)

Categories

Find more on Data Import and Analysis in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!