title: Read multiple txt files into Dict into Pandas dataframe
body: <p>I am trying to load multiple txt files into dataframe. I know how to load urls, csv, and excel, but I couldnt find any reference on how to load multiple txt files into dataframe and match with dictionary or viceversa.</p>
  
  <p>the text file are not comma or tab separated just plain text containing plain text song lyrics.</p>
  
  <p>I checked the pandas documents any assistance welcome.</p>
  
  <p><a href="https://pandas.pydata.org/pandas-docs/stable/reference/io.html" rel="nofollow noreferrer">https://pandas.pydata.org/pandas-docs/stable/reference/io.html</a></p>
  
  <p><strong>Ideally the dataframe</strong></p>
  
  <p>the dataframe I hope to achieve would be like this example</p>
  
  <pre><code>                 |                                                        lyrics
      -------------+-----------------------------------------------------------------------------------------
      bonjovi      |    some text from the text files HiHello! WelcomeThank you Thank you for coming.
      -------------+---------------------------------------------------------------------------------------
      lukebryan    |    some other text from the text files.Hi.Hello WelcomeThank you Thank you for coming. 
      -------------+-----------------------------------------------------------------------------------------
      johnprine    |    yet some text from the text files. Hi.Hello WelcomeThank you Thank you for coming. 
  
  </code></pre>
  
  <p><strong>Basic example</strong>
  folder structure /lyrics/</p>
  
  <pre><code>urls = 
  
      'lyrics/bonjovi.txt',
      'lyrics/lukebryan.txt',
      'lyrics/johnprine.txt',
      'lyrics/brunomars.txt',
      'lyrics/methodman.txt',
      'lyrics/bobmarley.txt',
      'lyrics/nickcannon.txt',
      'lyrics/weeknd.txt',
      'lyrics/dojacat.txt',
      'lyrics/ladygaga.txt',
      'lyrics/dualipa.txt',
      'lyrics/justinbieber.txt',]
  </code></pre>
  
  <p><strong>muscian names</strong></p>
  
  <pre><code>bands = ['bonjovi', 'lukebryan', 'johnprine', 'brunomars', 'methodman', 'bobmarley', 'nickcannon', 'weeknd', 'dojacat', 'ladygaga', 'dualipa', 'justinbieber']
  </code></pre>
  
  <p><strong>Open the text files</strong>
  the files are in directory lyrics/ from where I running my Jupyter notebook.</p>
  
  <pre><code>for i, c in enumerate(bands):
       with open("lyrics/" + c + ".txt", "wb") as file:
           pickle.dump(lyrics[i], file)
  </code></pre>
  
  <h1>Double check to make sure data has been loaded properly</h1>
  
  <pre><code>data.keys()
  </code></pre>
  
  <p><strong>hopefully get result like this</strong></p>
  
  <p>dict_keys(['bonjovi', 'lukebryan', 'johnprine', 'brunomars', 'methodman', 'bobmarley', 'nickcannon', 'weeknd', 'dojacat', 'ladygaga', 'dualipa', 'justinbieber'])</p>
  
  <pre><code># Combine it!
  data_combined = {key: [combine_text(value)] for (key, value) in data.items()}
  
  
  # We are going to change this to key: artist, value: string format
  def combine_text(list_of_text):
      '''Takes a list of text and combines them into one large chunk of text.'''
      combined_text = ' '.join(list_of_text)
      return combined_text
  </code></pre>
  
  <h1>We can either keep it in dictionary format or put it into a pandas dataframe</h1>
  
  <p>import pandas as pd</p>
  
  <pre><code>pd.set_option('max_colwidth',150)
  
  data_df = pd.DataFrame.from_dict(data_combined).transpose()
  data_df.columns = ['lyrics']
  data_df = data_df.sort_index()
  data_df
  </code></pre>