I have this text file containing transition lines of FeII emissions. The heads are: n_high, n_low, wavelength, intensity (where n_high and n_low are the upper and lower transitions, starting from
2 --> 1,,,371 --> 1,3 --> 2,,,371 --> 2,,, (and so on till the last chunk) 371 --> 370
The input file looks like:
#n_hi n_lo WL(A) logI
2 1 259811.86 1.158
3 1 149730.41 -2.054
4 1 115894.98 -2.134
5 1 102320.80 -2.389
6 1 53387.13 0.256
7 1 41138.69 -0.277
8 1 35226.70 -1.585
9 1 32068.36 -1.741
10 1 12566.77 2.323
.
.
.
.
369 1 1069.66 1.461
370 1 1065.75 -7.901
371 1 1065.64 -8.011
3 2 353390.47 0.759
4 2 209224.17 -2.390
5 2 168797.89 -2.607
.
.
.
370 369 291200.84 -10.337
371 369 283465.88 -10.436
371 370 10672868.00 -12.012
There are in total 68635 rows.
The task here is that I'd like to select only those specific transitions that are within the wavelength range, say [x1,x2] and print the entire row into another file.
So, what I have been able to do is sort of prepare an algorithm to do that:
for n_low from 1 to 370:
for n_hi from n_low+1 to 371:
if x2 <= wavelength <= x1:
print this row to file
else:
exit
I'd like to execute this using python.
pandasversus mucking with a csv reader. In pandas you can filter much more easily and consistently.