title: How to read file when the words are separated by "|" (PSV)?
body: <p>In Python, I have a file which the words are separated by <code>|</code>, for example: <code>city|state|zipcode</code>. My file reader is unable to separate the words. Also, I want my file reader to start on line 2 rather than line 1. How do I get my file reader to separate the words?</p>
  
  <pre><code>import os
  import sys
  
  def file_reader(path, num_fields, seperator = ',', header = False):
      try:
          fp = open(path, "r", encoding="utf-8")
      except FileNotFoundError:
          raise FileNotFoundError("Unable to open file.")
      else:
          with fp:
              for n, line in enumerate(fp, 1):
                  fields = line.rstrip('/n').split(seperator)
                  if len(fields) != num_fields:
                      raise ValueError("Unable to read file.")
                  elif n == 1 and header:
                      continue
                  else:
                      yield tuple([f.strip() for f in fields])
  </code></pre>