How to delete all rows in datafile that contain a string

I'm importing some data from a file. However, the file was created by an unreliable instrument, such that the data looks like this:

in: data = Import["D:\\6000s.txt", "Table"]
out: {...{5,0,46.4109},{6,0,46.6017},{7,0,No,Data},{8,0,45.7324}...}


The lines containing "No Data" can be safely deleted, but I don't know how to do this well. How can I efficiently map over my table and erase all rows that contain a string?

Edit: An example of my data is here . Also, a closely related question is here

Edit 2: @RunnyKine's and @MikeHoneyChurch's answers in the comments did the trick. I ended up doing the following:

data = Import["my_data.txt", "Table"];
data = DeleteCases[data, {__, _String, _String}]


This is much faster than the ugly for loops I had used previously. Thanks for your help!

• Can you give a sample of the file or a link to the actual file? A better way to read the file than using Import might be available. – RunnyKine Oct 30 '13 at 20:53
• Sure thing, @RunnyKine. I edited the question to include a link to an example datafile. – avn2109 Oct 30 '13 at 21:07
• If that is the structure then DeleteCases[yourData,{__,No Data}] and replace No Data with what is present e.g. a Null, empty string ... – Mike Honeychurch Oct 30 '13 at 21:08
• I think for your case, since you've successfully imported the data, doing what @MikeHoneychurch suggested is the way to go. But be careful since there's no list of the form {__, No Data} instead it should be DeleteCases[data, {__, No, Data} or just DeleteCases[data, {__, No, _}] – RunnyKine Oct 30 '13 at 21:19
• Welcome to Mathematica.SE, @avn2109! May I suggest actually posting the solution as an answer? That way people will know that this question already has an answer. – Verbeia Oct 30 '13 at 22:12

For many cases the suggested answer will work as desired. But the code using data most probably will expect a purely numerical array, probably even with a fixed length. I have found it to be more reliable in such cases to select those entries that match the expected pattern than to delete every particular form of rows not matching it. That is I'd rather suggest to use something like

Cases[data,{__?NumericQ}]


or

Select[data,VectorQ[#,NumericQ]&]


or even:

Cases[data, {_?NumericQ, _?NumericQ, _?NumericQ}]
Select[data, (VectorQ[#, NumericQ] && Length[#] == 3) &]


it might help to avoid troubleshooting the same thing again just because the instrument starts to report (other) errors in a different notation...

• That's less brittle and seems like a best practice in general. – avn2109 Nov 4 '13 at 23:37

This is just to get an answer on record so the question can be removed from not-answered list.

data = DeleteCases[Import["my_data.txt", "Table"], {__, _String, _String}]