MathGroup Archive 2008

[Date Index] [Thread Index] [Author Index]

Search the Archive

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

  • To: mathgroup at
  • Subject: [mg91808] Re: [mg91713] How can I do a "grep -v" equivalent in Import[]?
  • From: "peter lindsay" <pl.0 at>
  • Date: Tue, 9 Sep 2008 06:54:05 -0400 (EDT)
  • References: <>

sounds like you'd be better pre-processing and tidying the data [ with
C++ or realbasic or something similar ] before asking mathematica to
deal with it ?

2008/9/6 Jason Ledbetter <jasonbrent at>:
> Folk,
> I have some data that is column formatted with a dual line header every few
> lines; there may also be a variable number of lines between each header
> output. The first line is readily identifiable with say "grep ^FOO", but the
> second line in the header has white space at the beginning.
> So what I need to do is the equivalent of "grep -v" to get rid of the
> headers. My ultimate goal is to create a named List[] variable for each
> "column" in the data, but I need to get rid of the headers.
> Alternatively, I could regex match on the lines I DO want I think.. just
> trying to wrap my head around how to do this in Mathematica.
> For example, "egrep '^[0-9]+' foo.txt" gets me what I need in most shells...
> I'd just like mathematica to do the same on import.
> Do I need to process the import procedurally and dump the data I want into a
> new Table[]?
> I've been able to figure out how to get columnar data out of the import
> using "foo=data[[All,{1}]" and so on (e.g., first column in the data)... I
> just need to pre-filter the headers out.
> I apologize for the junior level of the question. :/
> Thanks!
> -jbl


  • Prev by Date: Re: how to convert output file to compatible format
  • Next by Date: Re: use vim to edit mathematica file
  • Previous by thread: How can I do a "grep -v" equivalent in Import[]?
  • Next by thread: Re: How can I do a "grep -v" equivalent in Import[]?