title: Is there a way to add a progress bar (such as tqdm) to PyYAML yaml.load() function?
body: <p>Using <code>PyYAML</code>, with <code>CLoader</code> as the <code>YAML</code> parser, I am attempting to load the <code>YAML</code> file, parse it and then write it to a separate file.</p>
  
  <p>For testing purposes, I am using a very large <code>YAML</code> file, larger than <code>1GB</code>.</p>
  
  <p>I am trying to include a progress bar to be displayed in the command line to show that my Python script is running and estimate how long it takes.</p>
  
  <p>Here is my current code:</p>
  
  <pre><code>import yaml
  import argparse
  
  from tqdm import tqdm
  from yaml import CLoader as Loader
  
  def main():
  
  parser = argparse.ArgumentParser(description='Takes in YAML files and uploads straight to Neo4J database')
  parser.add_argument('-f', '--files', nargs='+', metavar='', required=True,
                      help='&lt;Required&gt; One or more YAML files to upload')
  
  args = parser.parse_args()
  
  for file_name in args.files:
  
      with open(file_name, 'r') as stream:
          print("Reading input file...")
          with open('test2.txt', 'w') as wf:
              print("Writing to output file...")
  
              try:
                  for data in tqdm(yaml.load(stream, Loader=Loader)):
                      wf.write(data.get('primaryName') + '\n')
                      wf.write('++++++++++\n')
              except yaml.YAMLError as exc:
                  print(exc)
  
  if __name__ == "__main__":
      main()
  </code></pre>
  
  <p>What happens now is that there is a <code>tqdm</code> progress bar displayed for the data writing loop but not for the <code>yaml.load()</code> process which is the process that is taking the most time. </p>
  
  <p>That is, for a long time, no progress bar is shown until the <code>YAML</code> file is fully loaded.</p>
  
  <p>I am hoping to find a solution such that I am able to wrap a progress bar around a function that I have no access to, in this case, <code>yaml.load()</code>.</p>
  
  <p>Am I doing something wrong? Any advice will be great and appreciated.</p>