Delete rows with no entries in matrix

I have imported data. {{...},{...},{...},...{...}}

Here a screenshot:

As you can see there are empty entires {,,,,,,}

How can I delete those entries ?

If you want to delete rows that only consist of empty strings:

DeleteCases[data, {"" ..}]


"" .. is a pattern for "1 or more empty strings in a row". .. is shorthand for Repeated.

• Very elegant ! Good explenation! Thank you. – henry Aug 9 '16 at 15:35
• DeleteCases[{{1,""}, {2,""}, {}}, {"" ..}] doesn't give me the same result as I have in my answer. Perhaps I am missing something. – Eric Brown Aug 9 '16 at 15:44
• @Gerli: If I want to delete rows with Complex Number, then how do you revise your code above? – Tugrul Temel Dec 16 '19 at 19:53
• @TugrulTemel if you want to delete rows that only have complex numbers then instead of "" use _Complex as the pattern for the element to delete (ending up with {_Complex ..} -- or you can use {__Complex} which is equivalent in this case). From the wording of your question it seems like you might want to delete rows that contain a complex number, in which case the pattern you want could be {___, _Complex, ___} (0 or more elements, then a complex number, then 0 or more elements in the list) – Gerli Dec 18 '19 at 7:25
• @Gerli: I wanted to delete the rows with complex numbers, and your suggestion works fine. Thanks for your reply. – Tugrul Temel Dec 18 '19 at 13:50

Those are probably empty strings, so:

DeleteCases[{1,"",""}, ""]


will probably work for a single list. For lists of lists, you can use Map:

Map[ DeleteCases[#, ""] &, listOfLists]


If you would like to delete remaining empty rows, you can augment this with another DeleteCases:

DeleteCases[
Map[ DeleteCases[#, ""] &, listOfLists]
, {}]

• Hmm ... it is not working. It is working for your problem, but in my case I have rows witch are only empty strings. – henry Aug 9 '16 at 15:20
• Please try my edited response. – Eric Brown Aug 9 '16 at 15:24
• Very close... it delets all the empty entries but leaves the brakets {}. I have found a way to get rid of them. DeleteCases[Map[DeleteCases[#, ""] &, resMat], {}] – henry Aug 9 '16 at 15:27