# How do I remove parts of this data?

The data:

{{9.99758, 0}, {"", ""}, {10.0178, -21.7137}, {"", ""}, {10.038,
28.5723}, {"", ""}, {10.0582, 0.52409}, {"", ""}, {10.0784,
21.7378}, {"", ""}, {10.0987, 0}, {"", ""},...}


I need to remove the empty points, i.e. the {"", ""}, parts. I either need to find that pattern and remove it or simply remove every other point in this list.

In attempting to remove by pattern, I tried doing data /. Part[data, 2] -> "" but this returned:

{{9.99758, 0}, "", {10.0178, -21.7137}, "", {10.038,
28.5723}, "", {10.0582, 0.52409}, "", {10.0784,
21.7378}, "", {10.0987, 0}, "", {10.1189, 3.13778}, "",...}


How would I then finish it off by removing the "", part?

• Never mind, I just figured it out. It's simply data[[1;; ;; 2]] Oct 12, 2017 at 22:36
• DeleteCases[{data, {"", ""}] Oct 12, 2017 at 23:42

## Preparation

lst = {{9.99758, 0}, {"", ""}, {10.0178, -21.7137}, {"", ""}, {10.038, 28.5723}, {"", ""}, {10.0582, 0.52409}, {"", ""}, {10.0784, 21.7378}, {"", ""}, {10.0987, 0}, {"", ""}};


## Solution 1

As @tomd pointed, you can:

DeleteCases[lst, {"", ""}]
(* ==> {{9.99758, 0}, {10.0178, -21.7137}, {10.038, 28.5723}, {10.0582, 0.52409}, {10.0784, 21.7378}, {10.0987, 0}} *)


## Solution 2

Or else, you can still use Pattern Replace by:

lst /. {"", ""} -> Sequence[]
(* ==> {{9.99758, 0}, {10.0178, -21.7137}, {10.038, 28.5723}, {10.0582, 0.52409}, {10.0784, 21.7378}, {10.0987, 0}} *)

• {"", ""} -> Nothing works in newer versions. Oct 13, 2017 at 4:47
• @J.M. It works! Thank you! I know one more thing! Oct 13, 2017 at 4:49