<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:times new roman,new york,times,serif;font-size:12pt"><div>hi I have a file and it is in chunks:<br>I want to be able to select the number that follows 'Elution: '&nbsp; where the line startswith (TITLE)(say<br>
72.958) and check if it is larger than my choice of number (say<br>
71.4). If it is then I want to print chunk from BEGIN LINE to END<br>
LINE separated by one empty line.<br><br>I wrote the following script, when executed in IDEL or python mode, it works. however I use python test_script_test.py , I get name error:<br><br>could you please help me whats wrong here. <br>thanks<br><br><br>Command line mode:<br><br>$ python test_script_test.py<br>Traceback (most recent call last):<br>&nbsp; File "test_script_test.py", line 14, in &lt;module&gt;<br>&nbsp;&nbsp;&nbsp; newk = dat[mystartl:myfinish]<br>NameError: name 'myfinish' is not defined<br><br><br>In python mode:<br>&gt;&gt;&gt; f1 = open('test','r')<br>&gt;&gt;&gt; da = f1.read().split('\n')<br>&gt;&gt;&gt; dat = da[:-1]<br>&gt;&gt;&gt; mytimep = 71.4<br>&gt;&gt;&gt; for i in range(len(dat)):<br>...&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if dat[i].startswith('BEGIN LINE'):<br>...&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; mystartl =
 i<br>...&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if dat[i].startswith('END LINE'):<br>...&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; myfinish = i<br>...&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if dat[i].startswith('Title'):<br>...&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; col = dat[i].split(',')<br>...&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; x= float(col[2].split()[1])<br>...&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if x &gt; mytimep:<br>...&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; newk =
 dat[mystartl:myfinish]<br>...&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for x in newk:<br>...&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print x<br>...<br>BEGIN LINE<br>MYMASS=643.973587067287<br>CHARGE=2+<br>Title=File:xyx, sample= Cyst 7 band 7 (sample number 8), Elution: 72.958 to 73.198 min, Period: 1<br>132.4082 0.0323<br>133.0418 0.2596<br>136.0618 0.3276<br>138.0482 0.546<br>140.4848 0.0499<br>140.7096 0.0333<br>END LINE<br><br>BEGIN LINE<br>MYMASS=643.973587067287<br>CHARGE=2+<br>Title=File:xyx, sample= Cyst 7 band 7 (sample number 8), Elution: 72.958 to 73.198 min, Period: 1<br>132.4082 0.0323<br>133.0418 0.2596<br>136.0618 0.3276<br>138.0482 0.546<br>140.4848 0.0499<br>140.7096
 0.0333<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>my file:<br><br>BEGIN LINE<br>MYMASS=643.973587067287<br>CHARGE=2+<br>Title=File:xyx, sample= Cyst 7 band 7 (sample number 8), Elution: 72.958 to 73.198 min, Period: 1<br>132.4082 0.0323<br>133.0418 0.2596<br>136.0618 0.3276<br>138.0482 0.546<br>140.4848 0.0499<br>140.7096 0.0333<br>END LINE<br><br>BEGIN LINE<br>MYMASS=643.973587067287<br>CHARGE=2+<br>Title=File:xyx, sample= Cyst 7 band 7 (sample number 8), Elution: 72.958 to 73.198 min, Period: 1<br>132.4082 0.0323<br>133.0418 0.2596<br>136.0618 0.3276<br>138.0482 0.546<br>140.4848 0.0499<br>140.7096 0.0333<br>END LINE<br><br><br><br></div>
</div><br>

      </body></html>