# 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

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
• please add my solution to your response, so that I can validate your answer. :) – henry Aug 9 '16 at 15:28
• I made the edit. – Eric Brown Aug 9 '16 at 15:34