title: Writing variables to exact cell in Excel with Python
body: <p>So in order to refresh my powerBI dashboard I need to write queries to Excel. Otherwise I have to run every single query and do it myself.</p>
  <p>I now build the following Python code:</p>
  <pre><code>import pandas as pd
  from pathlib import Path
  
  data_folder = Path(&quot;PATH&quot;)
  
  file_to_open = data_folder / &quot;excelfile.xlsx&quot;
  
  df = pd.read_excel(file_to_open)
  
  query_1 = 5
  query_2 = 3
  query_3 = 12
  
  df.loc[df.iloc[-1,-1]+1,['A']] = query_1
  
  df.loc[df.iloc[-1,-1]+1,['B']] = query_2
  
  df.loc[df.iloc[-1,-1]+1,['C']] = query_3
  
  print(df) #for testing#
  
  df.to_excel(file_to_open, index = False)
  </code></pre>
  <p>It somehow puts query_1 in the right spot (right after the last value in column A)
  But query_2 and query_3 both skip one cell. They should all fill in the next empty cell in my excelsheet. My columns are A, B and C.</p>
  <p>Can someone help me out?</p>