Importing excel data that satisfies a criterion for a specific column

I am quite new in Mathematica and I really need help with something ... I have an excel file with a total of 5332 rows and 6 columns. Column 1 is my focus of interest. The first 2666 data of column 1 are descending from 190 to 30 and the rest are ascending from 30 to 190. I would like to import the data (all six columns) of rows for which the column 1 data are ascending from 60 to 160. I have tried using "Select" without any success. I'm also not sure at all of using both "Import" and "Select" in combination. Any help will be greatly appreciated!!

Best Wishes Naz

Since you want ascending, and that depends on comparing pairs of items, we can group together each adjacent pair of items, test each pair to see if it qualifies and then take the first item from each pair.

First I make some fake data

matrix={
{6,1,1,1,1,1},
{5,2,2,2,2,2},
{4,3,3,3,3,3},
{60,4,4,4,4,4},
{61,5,5,5,5,5},
{62,6,6,6,6,6},
{190,7,7,7,7,7}};


And then use Partition to pair up the items, Select to decide if each pair is acceptable and finally Map[First to keep the first item and discard the second item of each pair.

ascending=Map[First,Select[Partition[matrix,2,1],#[[2,1]]>#[[1,1]]&&60<=#[[1,1]]<=160&]]


the result from that is

{{60,4,4,4,4,4},{61,5,5,5,5,5},{62,6,6,6,6,6}}


There is a lot going on in that for someone who is new. See if you can look up each of those functions in the help system. # and & are parts of "anonymous functions", functions that don't even get given a name and are just used in that line and perhaps never again.

A different way of writing that might be easier for someone new to understand.

test[{{x1_,_,_,_,_,_},{x2_,_,_,_,_,_}}]:=x1<x2&&60<=x1<=160;
ascending=Map[First,Select[Partition[matrix,2,1],test]]


Try this on your actual data and see if it works. Make sure you have removed enough extra layers of {} that imported csv files sometimes have.

• Hi Bill, I was so much into making my code work, I completely forgot to thank you, my sincere apologies!!!!! It worked perfectly. Thank you so very much again and Take Care man! Oct 9, 2020 at 16:08