title: How can I convert a dataframe to csv and save it to return it?
body: <p>I'm reading a .xlsx file and converting it to .csv but I need to return it as a .csv because I don't have access to the path where it should be stored. I've only been able to return it as a dataframe. Any help will be really appreciated. Thanks.</p>
  
  <pre class="lang-py prettyprint-override"><code>import pandas as pd
  
  
  def excel_to_csv(myfile):
      print(myfile)
      data_xls = pd.read_excel(myfile,  index_col=None)
      data_xls.to_csv(encoding='utf-8', index=False)
      return(data_xls)
  
  myfile = request.FILES['file']
  if myfile.name.endswith('.xlsx'):
      myfile=excel_to_csv(myfile)
  
  
  
  </code></pre>