title: How to speed up excel file writing using Pythonwin32.com
body: <p>I am reading data from an ascii file into an array and writing the data into an excel file for futher post processing . There are total of 337 columns and 1100 rows -- that makes 370700 cells in xlsx.</p>
  
  <p>Writing the excel data file is taking very long time -- approximately 25-35 minutes on 16 GB machine.</p>
  
  <p>Is there any other method to write data in excel file more efficiently ?</p>
  
  <p>Any help would be appriciated.</p>
  
  <pre><code>import numpy as np 
  import win32com.client as win32 
  import matplotlib.pyplot as plt 
  from win32com import client  from time
  clock, time  start_time = clock()
  
  itr = int(raw_input('Enter number of iteration = '))
  f1 =open("Case_AT-6_WF_fl2.gid","r")
  
  s2 = f1.read() 
  a = s2.split() 
  
  count=0 for col in open("Case_AT-6_WF_fl2.gid",'r'):
  count = count+1 column = int(len(col.split()))
  sm = int(itr * column)
  
  digit = map(float,(a[(len(a)-sm):l
  a[(column+7):(column*2+7)]
  
  # preparing 2D matrix dig = np.array(digit)  dig1 =(dig.reshape
  
  ### *******Plotting
  ## print name
  
  for i in range(len(name)):    
      print i,"=",name[i]
  
  plot = int(raw_input("\nEnter variable number for plot =" ))
  
  # writing Excel file*******************************************
  
  print('file printing option: 1 = Yes 2= No') q = int(raw_input(
  printing option = "))
  
  if q==1 :
      excel = win32.gencache.EnsureDispatch('Excel.Application')
      excel.Visible = False
      wb = excel.Workbooks.Add()
      ws=wb.Sheets(1)
      ws.Name = "MyData"
      ws.Activate
      for kk in range(len(name)):
          ws.Cells(2,kk+1).Value = name[kk]
          ws.Cells(3,kk+1).Value = unit[kk]
  m = 0
  k =0
  for j in range(itr):
      for k in range(column):
          ws.Cells(j+5,k+1).Value=dig1[j][k]
          m = m+1
         print '',m
  print clock() - start_time, "seconds"
  
  wb.SaveAs('C:\\Documents andSettings\\sd47086\\Desktop\\test\\MyWorkbook3.xlsx')
  excel.Application.Quit()
  </code></pre>