title: Skip one line - python open with
body: <p>How I can skip first header line? I have headers duplicated later in the code, so I can eliminate them by if not l.startswith('MANDT') but first header I want to keep. How I need to modify the code? </p>
  
  <pre><code>keep -&gt; MANDT|BUKRS|NETWR|UMSKS|UMSKZ|AUGDT|AUGBL|ZUONR
  100|1000|23.321-|||||TEXT
  100|1000|0.12|||||TEXT
  100|1500|90|||||TEXT
  remove -&gt; MANDT|BUKRS|NETWR|UMSKS|UMSKZ|AUGDT|AUGBL|ZUONR
  100|1000|23.321-|||||TEXT
  100|1000|0.12|||||TEXT
  100|1500|90|||||TEXT
  remove -&gt; MANDT|BUKRS|NETWR|UMSKS|UMSKZ|AUGDT|AUGBL|ZUONR
  </code></pre>
  
  <p>Code I am using. </p>
  
  <pre><code>with open('yourfile.txt', 'r+') as f:  # 'r+' - read/write mode
      lines = f.read().splitlines()
      f.seek(0)  # reset file pointer
      f.truncate()  # truncating file contents
      for l in lines:
          if not l.startswith('---'):
              # or f.write('|'.join(map(str.strip, l.strip('|').split('|'))) + '\n')
              f.write(re.sub(r'\|\s*|\s*\|', '|', l).strip('|') + '\n')
  </code></pre>