Extraction of the third column in multiple excel files

11 views (last 30 days)
Hi all I have a folder on my computer with 300 txt files and I don't want to manually extract the row of the minimum value in the third column with the header (CSA mm^2) from every excel file manually and combine into a single excel file.
I was wondering how I can do this on Matlab through reading every Excel file in that specific file and taking out all of the rows that contain the min CSA value in the excel and then combining all that into a excel file?
-----
note: the code for retrieving the rows is working - I cant figure out why the min function does not work
Thanks in advance for the help!
I have attached some files. I want to extract the row with the lowest CSA value.
  1 Comment
Benjamin Thompson
Benjamin Thompson on 10 Oct 2022
Just for better cyber safety for the Community could you replace XLS files with XLSX?

Sign in to comment.

Answers (1)

Image Analyst
Image Analyst on 10 Oct 2022
Try this:
CSA_cols = data(:,3); % Extract column 3
% Find min value
minimum_val = min(CSA_cols);
% Find all rows where the minimum occurs
minRows = find(CSA_cols == minimum_val);
% Get matrix with only those rows
extractedMatrix = data(minRows, :);
To process a sequence of workbook files, see the FAQ:
  11 Comments
Random User
Random User on 13 Oct 2022
Edited: Random User on 13 Oct 2022
Thats weird, when I open it on my end they look fine - try these files
Image Analyst
Image Analyst on 13 Oct 2022
They do look normal in Notepad, but when reading into MATLAB they are gibberish
data = readtable(fullFileName)
data = readmatrix(fullFileName)
readtable() and importdata() give a bunch of nonsense, and readmatrix gives all nans. I think there is something wrong with them. Are they 16 bit unicode characters or something?
Call tech support and give them that file and ask

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!