Re: How can I do a "grep -v" equivalent in Import[]?

*To*: mathgroup at smc.vnet.net*Subject*: [mg91855] Re: How can I do a "grep -v" equivalent in Import[]?*From*: Bill Rowe <readnews at sbcglobal.net>*Date*: Wed, 10 Sep 2008 05:09:37 -0400 (EDT)

On 9/9/08 at 6:56 AM, jasonbrent at gmail.com (Jason Ledbetter) wrote: >I've done the following: >importTemp = Import[ToFileName[Directory[], "input.txt"], >{"Lines"}]; regexMatch = "^\d{2}.*"; sysstat = >StringCases[importTemp, RegularExpression[regexMatch]]; >which gets me ALMOST what I'm looking for.... I end up with the the >non-matched lines being empty data sets which Part:partw doesn't >like. >e.g. output is like this: >{{}, {}, {"24"}, {"29"}, ... This last is easily dealt with using DeleteCases That is if StringCases[importTemp, RegularExpression[regexMatch]] produces the output you showed then DeleteCases[StringCases[importTemp, RegularExpression[regexMatch]],{}] will produce {{"24"}, {"29"}, ...