title: Get name attribute of IO_Bufferedreader
body: <p>What I am wanting to do is use the name of the current file I have that is from a generator and use the first section of the name + append .csv</p>
  
  <p>The buffered stream looks like this</p>
  
  <pre><code>&lt;_io.BufferedReader name='data/20160107W FM0.xml'&gt;
  </code></pre>
  
  <p>I am having an issue with this code:</p>
  
  <pre><code>for file_to_read in roots:
          print(file_to_read)
          base = os.path.basename(file_to_read)
          print(base)
          name_to_write = os.path.splitext(file_to_read)[0]
          outname = str(name_to_write[0]) + ".csv"
          outdir = "output"
          with open(os.path.join(outdir, outname), 'w', newline='') as csvf:
  </code></pre>
  
  <p>I receive this error which I believe means I am trying to split the stream rather than the name attribute of the buffered stream. Which leads me to this error.</p>
  
  <pre><code>$ python race.py data/ -e .xml
  &lt;_io.BufferedReader name='data/20160107W FM0.xml'&gt;
  Traceback (most recent call last):
    File "race.py", line 106, in &lt;module&gt;
      data_attr(rootObs)
    File "race.py", line 40, in data_attr
      base = os.path.basename(file_to_read)
    File "C:\Users\Sayth\Anaconda3\lib\ntpath.py", line 232, in basename
      return split(p)[1]
    File "C:\Users\Sayth\Anaconda3\lib\ntpath.py", line 204, in split
      d, p = splitdrive(p)
    File "C:\Users\Sayth\Anaconda3\lib\ntpath.py", line 139, in splitdrive
      if len(p) &gt;= 2:
  TypeError: object of type '_io.BufferedReader' has no len()
  </code></pre>
  
  <p>My expected output is:</p>
  
  <pre><code>20160107W FM0.csv 
  </code></pre>