Re: How can I do a "grep -v" equivalent in Import[]?
- To: mathgroup at smc.vnet.net
- Subject: [mg91806] Re: How can I do a "grep -v" equivalent in Import[]?
- From: David Bailey <dave at Remove_Thisdbailey.co.uk>
- Date: Mon, 8 Sep 2008 06:10:29 -0400 (EDT)
- References: <g9t6mq$j8s$1@smc.vnet.net>
Jason Ledbetter wrote: > 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 > > I think that if you post a TINY example of your input file, together with the corresponding output that you wish to obtain, someone will give you an answer. As it is, your question is a bit vague. David Bailey http://www.dbaileyconsultancy.co.uk
- Follow-Ups:
- Re: How can I do a "grep -v" equivalent in Import[]?
- From: "Jason Ledbetter" <jasonbrent@gmail.com>
- Re: How can I do a "grep -v" equivalent in Import[]?