title: Streamlit - IF statement depending on text_input
body: <p>There is an error message (KeyError: '') for line 25,26 when the text inputs are empty but I can't manage to get rid of it. I want the variables Vec1 and Vec2 to be stored only when there exists a text input for both widgets. To run the code, you can load any xlsx table, like this one:</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>Var1</th>
  <th>Var2</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>5</td>
  <td>7</td>
  </tr>
  <tr>
  <td>6</td>
  <td>8</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>Here is my code</p>
  <pre><code>import numpy as np 
  import pandas as pd
  import streamlit as st
  
  st.set_page_config(layout=&quot;wide&quot;)
  
  #Import file
  xlsx_file = st.sidebar.file_uploader('Import File', type = 'xlsx') 
  
  #Select Variables of interest
  Vec1Name = st.sidebar.text_input(&quot;First Variable Name&quot;)
  Vec2Name = st.sidebar.text_input(&quot;Second Variable Name&quot;)
  
  st.title('Data')
  col1, col2 = st.columns((3,1))
  
  if xlsx_file is not None:
      df = pd.read_excel(xlsx_file)
      col1.write(''' #### Dataframe''')
      col1.write(df)
      
      if all(var is not None for var in [Vec1Name, Vec2Name]):
          
          #Store Variables
          Vec1 = df[str(Vec1Name)]
          Vec2 = df[str(Vec2Name)]
  
          #Variables of Interest
          col2.write(''' #### Variables of Interest''')
          col2.write(df[[str(Vec1Name),str(Vec2Name)]])
  </code></pre>
  <p>Thank you for your help!</p>