title: Extracting/Separate records with duplicate and unique values from File Python
body: <p>I have one input file with following values:</p>
  
  <pre><code>file1.txt
  
  Name       ID    Code
  ABC        12    322
  QWE        97    214
  ASD        86    111
  FGH        12    322
  RTY        86    322
  BNM        86    214
  POK        12    111
  MKI        33    322
  </code></pre>
  
  <p>I want to generate multiple files based on duplication of <code>ID</code>. When above file will be given as input then output will be:</p>
  
  <p>First File</p>
  
  <pre><code>12.txt
  ABC        12    322
  FGH        12    322
  POK        12    111
  </code></pre>
  
  <p>Second File</p>
  
  <pre><code>97.txt
  QWE        97    214
  </code></pre>
  
  <p>Third File</p>
  
  <pre><code>86.txt
  ASD        86    111
  RTY        86    322
  BNM        86    214
  </code></pre>
  
  <p>Fourth File</p>
  
  <pre><code>33.txt
  MKI        33    322
  </code></pre>
  
  <p>All the records with same IDs will be stored in one and if there is no duplicate just store in another file. Filename should be <code>ID.txt</code>.</p>
  
  <p><code>.txt File</code> as input is mendatory and in txt file there are character wise as there is some value of each space.</p>
  
  <p>Thanks</p>