title: split large xlsx to multiple csv file using python
body: <p>I am trying to generate multiple csv file by splitting single large xls file using pandas, but only generates a single small file, rest files are not getting generated. Please find the below sample function.</p>
  <pre><code>def xls_split_to_csv(sourceFilePath):
  curr_date = datetime.now().strftime(&quot;%d-%m-%Y&quot;)
  curr_time = datetime.now().strftime(&quot;%H-%M-%S&quot;)
  try:
      logMessage(&quot;--------------------------------------------------------&quot;)
      logMessage(f'######### Split engine started - {curr_date}  ##########')
      logMessage(&quot;--------------------------------------------------------&quot;)
      chunk_size = config_params['split_size']
      batch = 0
      df = pd.read_excel(sourceFilePath)
      o_filename = f'file_{curr_date}_{curr_time}_{batch + 1}.csv'
      file_count = math.ceil(len(df) / chunk_size)
      for chunk in np.array_split(df, file_count):
          logMessage(f'Splitting file ----&gt; ({batch + 1} of {file_count})')
          output_path = os.path.join('../TruncatedFile', o_filename)
          chunk.to_csv(output_path, index=False, header=True)
          batch += 1
  
  except ZeroDivisionError as zeroEx:
      logError(&quot;Exception: &quot;)
  except Exception as ex:
      logError(&quot;Exception: &quot;)
  </code></pre>