How to drop columns of csv data in J

Viewed 115

I have a lot of csv files that I have to drop the date column.

I have a J line that reads in csv file into a numeric array, rdtabfile =: (0&".;.2@:(TAB&,)@:}:);._2) @ ReadFile @<

1 Answers

If you know the column number of the date column, I would just use a mask across each line of the array and the copy # dyadic verb.

   [ t =: i. 4 5
 0  1  2  3  4
 5  6  7  8  9
10 11 12 13 14
15 16 17 18 19
   mask=: ~: [: i. #  NB. x would be the column to be dropped, y is the numeric matrix
   delcol=: (mask # ])"1
   1 delcol t
 0  2  3  4
 5  7  8  9
10 12 13 14
15 17 18 19
   delcola=: ((~: [: i. #) # ])"1 NB. can be done in one line
   2 delcola t
 0  1  3  4
 5  6  8  9
10 11 13 14
15 16 18 19
Related