Note that there are some explanatory texts on larger screens.

plurals
  1. POconfiguring a nested if loop to categorize a dataset
    primarykey
    data
    text
    <p>i have a file with following data:</p> <pre><code>line EF1 1 F Flu 5.7 3.221 9.332 line A2 1 C Car 3.2 5.22 1.22 line A1 1 C Car 3.11 4.21 2.13 line HF1 1 H Hyd 7.11 5.11 7.11 line EE2 1 F Flu 5.7 3.221 9.332 line A2 2 C Car 3.2 5.22 1.22 line EF1 2 F Flu 5.7 3.221 9.332 line EE2 2 F Flu 5.7 3.221 9.332 line A1 2 C Car 3.11 4.21 2.13 line HE2 2 H Hyd 7.11 5.11 7.11 </code></pre> <p>...1000+ lines.</p> <p>Here column no 3 represents Chain number. Now I have created different lists named : <code>EF</code> ,<code>EE</code>, <code>H</code> and <code>ace</code>. What I wanted to do is, if <code>EF1</code> and <code>HE1</code> both present from same <code>chain number</code> then write <code>EF data</code> in <code>'EF list'</code> and <code>HE data</code> in <code>H list</code>. On the other hand if only <code>'EF1'</code> present but no <code>HE1</code> in the same <code>chain number</code> then write it in <code>'ace list'</code>.</p> <p>Desired output is: </p> <pre><code>EF list: line EF1 1 F Flu 5.7 3.221 9.332 line EE2 2 F Flu 5.7 3.221 9.332 H list: line HF1 1 H Hyd 7.11 5.11 7.11 line HE2 2 H Hyd 7.11 5.11 7.11 ace list: line EE2 1 F Flu 5.7 3.221 9.332 line EF1 2 F Flu 5.7 3.221 9.332 </code></pre> <p>Now i was trying like,</p> <pre><code>inp = filename.read().strip().split('\n') for line in map(str.split,inp): codeName = line[1] shortName = line[3] </code></pre> <p>now as a rookie i am really lost here about how could i be able construct an <code>if loop</code> to get this checking done.<br> please provide some ideas on how could i progress on this !! (i was mistaken for my formatting error first time. corrected it!)</p>
    singulars
    1. This table or related slice is empty.
    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