Note that there are some explanatory texts on larger screens.

plurals
  1. PORead a large file and output sections matching multiple parameters
    primarykey
    data
    text
    <p>I rarely have to deal with scripting, so I'm up against a lack of knowledge for this problem.</p> <p>I have a file >500mb in text, which is nicely sectioned, but I know there are 5 to 10 "bad" sections inside. The data within the sections can be evaluated pretty easily by a human, I don't know how to do it in a program.</p> <p>I pick up a known good value in <code>#Field MyField</code> - however if that value did not appear in <code>#FIELD LOCATION</code>, something went wrong.</p> <p>An example of two sections within the file looks like this. The first is 'bad' and the second is 'good'.</p> <pre class="lang-none prettyprint-override"><code>#START Descriptor #FIELD LOCATION="http://path.to/file/here&amp;Value=FOO&amp;OtherValue=BLAH" #FIELD AnythingElse #FIELD MyField="BAR" #END #START Descriptor #FIELD LOCATION="http://path.to/file/here&amp;Value=BAR&amp;OtherValue=BLAH" #FIELD AnythingElse #FIELD MyField="BAR" #END </code></pre> <ol> <li><p>Sections start and end logically, with <code>#START</code> and <code>#END</code></p></li> <li><p>If <code>#FIELD LOCATION</code> does not exist, go to next section</p></li> <li><p>If <code>#FIELD MyField="BAR"</code> and <code>#FIELD LOCATION</code> does not contain <code>BAR</code>, print all lines from this section to a new file.</p></li> <li><p>Note - Clarification of <code>#FIELD MyField="BAR"</code> - this is a check value I put in by grabbing other info about the data as this file is being built (in my case it is a language indicator, such as EN or DE. so it would literally be <code>#FIELD MyField="EN"</code> Any other value in this field would be ignored, this isn't a record that matches my criteria. </p></li> </ol> <p>I believe this can be done in Awk or Perl, I can do very simple one-liners but this is beyond my skills.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload