title: checking folder exisits, otherwise create one and write excel to excel into it
body: <p>I have long analysis during which I need to write the results (tables) to an Excel file. To avoid writing the codes multiple times throughout the analysis, I created function: Its purpose is:</p>
  <ol>
  <li>Check if folder exist or not</li>
  <li>If folder exist, just write the data frame into an excel file into this folder</li>
  <li>If folder not found, create new folder and then write the excel file into it</li>
  </ol>
  <p>It used to work but not anymore, now it neither gives an error nor any outputs as if I executed empty cell. I don't understand why, any help is highly appreciated</p>
  <pre><code>def dfToExcel(df,filename,sheet_name,index,sub_dir=None):    
                     
      current_path = os.getcwd()
      
      if sub_dir != None:
          path = current_path+'\\'+ sub_dir 
          ispath = Path(path).exists()
          if ispath == False:
             os.mkdir(path) 
          
          file_path= path+'\\'+ filename
      else:        
          file_path=current_path+'\\'+ filename
          
      ispath = Path(file_path).exists()
      if ispath == False:
          df.to_excel(file_path ,sheet_name=sheet_name,index=index,engine = 'xlsxwriter')        
      else:
          with pd.ExcelWriter(file_path,mode='a',engine = 'openpyxl') as writer:    
              df.to_excel(writer,sheet_name=sheet_name, index=index,encoding='iso-8859-1')
  </code></pre>