I have a list that has several empty lists inside it. I followed the directions here (Python: How to remove empty lists from a list?) in an attempt to filter out the empty lists but failed and I really have no reason why.
My list:
data: [['#0721', '', '', '', ''], ['', '', '', '', ''], ['', '', '', '', ''], ['GBE COD', '746', '$2.00', '', '$1,492.00'], ['GBW COD', '13,894', '$0.50', '', '$6,947.00'], ['GOM COD', '60', '$2.00', '', '$120.00'], ['GB WINTER FLOUNDER', '94,158', '$0.25', '', '$23,539.50'], ['GOM WINTER FLOUNDER', '3,030', '$0.50', '', '$1,515.00'], ['GBE HADDOCK', '18,479', '$0.02', '', '$369.58'], ['GOM HADDOCK', '0', '$0.02', '', '$0.00'], ['GBW HADDOCK', '110,470', '$0.02', '', '$2,209.40'], ['HAKE', '259', '$1.30', '', '$336.70'], ['PLAICE', '3,738', '$0.40', '', '$1,495.20'], ['POLLOCK', '3,265', '$0.02', '', '$65.30'], ['WITCH FLOUNDER', '1,134', '$1.30', '', '$1,474.20'], ['SNE YT', '1,458', '$0.65', '', '$947.70'], ['GB YT', '4,499', '$0.70', '', '$3,149.30'], ['REDFISH', '841', '$0.02', '', '$16.82'], ['', '', '', '', ''], ['', '', '', '', ''], ['54 DAS @ $8.00/DAY = 432.00', '', ''], ['', '', '', '', '', '', '', '', ''], ['', '', '', '', '', '', '', '', '']]
My code:
data = filter(None, data)
print("second data:", data)
data = list(data)
print("third data:", data)
Which produces:
second data: <filter object at 0x05F23CF0>
third data: [['#0721', '', '', '', ''], ['', '', '', '', ''], ['', '', '', '', ''], ['GBE COD', '746', '$2.00', '', '$1,492.00'], ['GBW COD', '13,894', '$0.50', '', '$6,947.00'], ['GOM COD', '60', '$2.00', '', '$120.00'], ['GB WINTER FLOUNDER', '94,158', '$0.25', '', '$23,539.50'], ['GOM WINTER FLOUNDER', '3,030', '$0.50', '', '$1,515.00'], ['GBE HADDOCK', '18,479', '$0.02', '', '$369.58'], ['GOM HADDOCK', '0', '$0.02', '', '$0.00'], ['GBW HADDOCK', '110,470', '$0.02', '', '$2,209.40'], ['HAKE', '259', '$1.30', '', '$336.70'], ['PLAICE', '3,738', '$0.40', '', '$1,495.20'], ['POLLOCK', '3,265', '$0.02', '', '$65.30'], ['WITCH FLOUNDER', '1,134', '$1.30', '', '$1,474.20'], ['SNE YT', '1,458', '$0.65', '', '$947.70'], ['GB YT', '4,499', '$0.70', '', '$3,149.30'], ['REDFISH', '841', '$0.02', '', '$16.82'], ['', '', '', '', ''], ['', '', '', '', ''], ['54 DAS @ $8.00/DAY = 432.00', '', ''], ['', '', '', '', '', '', '', '', ''], ['', '', '', '', '', '', '', '', '']]
So it didn't end up doing anything, why is that?