title: Python input and output data in excel
body: <p>I'm really new in programming and Python. I would like to ask some newbie questions. I have an excel file which have words in a column. I want to read those word an generate the synonyms word in another excel file. Below is the words that i want to read from excel:</p>
  
  <pre><code>     |      A         |      B      |      C
  
  1    |    mankind     |   liquid    |     air    
  
  2    |    professor   |   steam     |     haze 
  
  3    |    name        |   kind      |     awkward       
  
  4    |    went        |   save      |     enemy
  </code></pre>
  
  <p>And this is my code:`</p>
  
  <pre><code>import nltk
  import xlrd
  import csv
  import xlwt
  import xlsxwriter
  from nltk.corpus import stopwords
  from nltk.tokenize import word_tokenize
  from nltk.corpus import wordnet
  
  workbook = xlrd.open_workbook('C:\\Users\\runeza\Desktop\database.xlsx')
  sheet_names = workbook.sheet_names()
  sheet = workbook.sheet_by_name(sheet_names[0])
  
  row_idx = 0
  
  for col_idx in range(sheet.ncols):
      for row_idx in range(sheet.nrows):
          cell = sheet.cell(row_idx, col_idx).value #read content in column cell
          synonyms = []
  
          for syn in wordnet.synsets(cell):
              for l in syn.lemmas():
                  synonyms.append(l.name())
                  a = (set(synonyms))
          #print (a)
                  wb = xlwt.Workbook()
                  ws = wb.add_sheet("test")
                  for i, col in enumerate(a):
                      for j, row in enumerate(col):
                          ws.write(i, j, col)
          wb.save("sample.xls")
  </code></pre>
  
  <p>`</p>
  
  <p>However, this code does not translate all the words. In the output excel, it just print out the last word only and repeat the words in each column based on the number of letter.</p>