How to create new wave from existing wave

I have a table consisting of multiple waves. I want to extract only specific rows of data depending on the status indicated by one of the columns. This is an example of the data:

Column 1 column 2 column 3 column 4 column 5
03/08/2017 cf0000 0.45 0.300 0.298
04/08/2017 cf0200 0.4 0.6 0.3
05/08/2017 cf0000 0.5 0.2 0.1


in the example above, I only want to extract the values from the row that has the status cf0200 and put it in a new table (all values from column, 1, 2, 3, 4, and 5 will be transferred to the new table if column 2 has cf0200). How would I program this? I am new to igor and am having a lot of trouble trying to figure out the code for this. Any help would be appreciated!
For use in the command line.
extract column1, c1, StringMatch(column1, "cf0200")
extract column2, c2, StringMatch(column1, "cf0200")
extract column3, c3, StringMatch(column1, "cf0200")
extract column4, c4, StringMatch(column1, "cf0200")
extract column5, c5, StringMatch(column1, "cf0200")
edit c1, c2, c3, c4, c5


Use a for loop in a procedure file
function extr()
variable i
wave /T column2
    for (i=1;i<6;i+=1)
        extract $("column"+num2str(i)), $("c"+num2str(i)), StringMatch(column1, "cf0200")
    endfor
    edit c1, c2, c3, c4, c5
end


I assume column2 is text based and not hex formatted numbers. Otherwise, replace StringMatch(column1, "cf0200") by column2==0xcf0200) and wave /T column2 by wave column2.

In case you want to overwrite the source waves, use 'columnX' instead of 'cX' together with the /O flag for extract AND make sure your 'marker column' (column2) is processed last. Here, the existing table will update automatically and you won't need that edit command at the end of each code.

HJ


If I were you I would work only on numerical data (i.e. convert dates, convert status codes)

The date I would convert to Julian: datetojulian(2017,08,03) (displayhelptopic "dateToJulian")

The status code I would convert appropriately (idk how many status codes you have, is RAM an issue, etc.).

Then use something like that:

function thunk_extract(w_in)
    wave w_in
   
    variable i
    variable v_nrows = dimsize(w_in, 0)
    string s_row
   
    for (i=0; i<v_nrows; i+=1)
        sprintf s_row, "w_row%d", i
        matrixop/o $s_row = row(w_in,i)^t
    endfor
   
    for (i=0; i<v_nrows; i+=1)
                //s_row = "w_row1"
        sprintf s_row, "w_row%d", i
        wave w_row = $s_row
        print w_row
    endfor 
   
end


best,
_sk
Quote:
If I were you I would work only on numerical data (i.e. convert dates, convert status codes)


An Igor date/time value is numeric - seconds since 1904-01-01:
DisplayHelpTopic "Date/Time Waves"

I don't think it is a good idea to convert to Julian because some Igor operations expect Igor date/time format. For example, it must be Igor date/time format to use as the X axis in a graph.
hrodstein][quote wrote:
I don't think it is a good idea to convert to Julian because some Igor operations expect Igor date/time format. For example, it must be Igor date/time format to use as the X axis in a graph.


Good to know.

best,
_sk