Deleting unnecessary elements in a list from columns where each row

I have a table with 3 columns: bid_price and bid_size, db_name

bid_price, bid_size, db_name column for example has multiple entries (each of the entry is a list ). Below is an example:

bid_price         bid_size         db_name    

5 4 3 2 1         10 20 30 40    nasdaqnyseicecboe

4 3 1               30 10 20        nysecboe`nasdaq

Now I only want each entry to have number of elements such that the bid size is 31.

That is the resultant table should look like: 

bid_price         bid_size        db_name

5 4 3              10 20 30        nasdaqnyse`ice

4 3                 30 10            nysecboe

Do note that in the above table I deleted bid_prices and db_names that were extra to keep the number of bid prices and db_names consistent with bid size. How do I do this?

Let me know if the question is not clear?

how about

q)t:flipbid_pricebid_sizedb_name!((5 4 3 2 1;4 3 1);(10 20 30 40;30 10 20);(nasdaqnyseicecboe;nysecboenasdaq))

q)({min(count x;1+sumsbinr 31)}@'tbid_size)#''t<br>bid_price bid_size db_name <br>-----------------------------------<br>5 4 3 10 20 30 nasdaqnyseice
4 3 30 10 nysecboe

On Fri, May 8, 2015 at 12:55 PM, Varun Tomar <varun.umich@gmail.com> wrote:

> I have a table with 3 columns: bid_price and bid_size, db_name
>
> bid_price, bid_size, db_name column for example has multiple entries (each of the entry is a list ). Below is an example:
>
> bid_price         bid_size         db_name    
>
> 5 4 3 2 1         10 20 30 40    nasdaqnyseicecboe
> 4 3 1               30 10 20        nysecboenasdaq \> \> Now I only want each entry to have number of elements such that the bid size is 31. \> \> That is the resultant table should look like: \> \> bid\_price &nbsp; &nbsp; &nbsp; &nbsp; bid\_size &nbsp; &nbsp; &nbsp; &nbsp;db\_name \> \> 5 4 3 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;10 20 30 &nbsp; &nbsp; &nbsp; &nbsp;nasdaqnyseice
> 4 3                 30 10            nysecboe
>
> Do note that in the above table I deleted bid_prices and db_names that were extra to keep the number of bid prices and db_names consistent with bid size. How do I do this?
>
> Let me know if the question is not clear?
>

thanks a ton Charles! that was magic!