#!/usr/bin/env python

import sys, os

# read
from openpyxl import load_workbook
# write
from openpyxl import Workbook

from openpyxl.compat import range
from openpyxl.cell import get_column_letter

#sys.path.append(os.path.abspath(os.path.join('..', 'excely')))
#from excely import blah

# http://stackoverflow.com/questions/419163/what-does-if-name-main-do
if __name__ == '__main__':

    def spelled_word(in_word):
        """
        returns spelled_word
        """
        return in_word + 'foo'

    """
    Read from Excel file in.xlsx and write to out.xlsx
    """
    # input file in project root directory
    in_filename = 'in.xlsx'
    in_workbook = load_workbook(in_filename)
    # ['Sheet 1']
    print(in_workbook.sheetnames)
    in_sheet = in_workbook.active
    print('in_sheet name ', in_workbook.sheetnames[0])

    out_workbook = Workbook()
    out_sheet = out_workbook.active
    out_sheet.title = "my_sheet"
    # output file in project root directory
    out_filename = 'out.xlsx'

    # http://stackoverflow.com/questions/37440855/how-do-i-iterate-through-cells-in-a-specific-column-using-openpyxl-1-6
    first_non_header_row = 2
    # column to read in in_sheet
    in_column = 2
    # column to write in out_sheet
    out_column = 1

    for row in range(first_non_header_row, in_sheet.max_row + 1):
        in_word = in_sheet.cell(row=row, column=in_column).value
        out_word = spelled_word(in_word)
        print(in_word + ', ' + out_word)
        # out_sheet set cell value
        _ = out_sheet.cell(column=out_column, row=row, value=out_word)

    out_workbook.save(filename = out_filename)


@@ -496,28 +496,65 @@
  'foo'%0A%0A    
-%22%22%22%0A
+def read_in_write_out():%0A        %22%22%22%0A    
     Read fro
@@ -596,24 +596,28 @@
 ut.xlsx%0A
+    
     %22%22%22%0A
     # in
@@ -604,24 +604,28 @@
         %22%22%22%0A
+    
     # input 
@@ -651,24 +651,28 @@
 t directory%0A
+    
     in_filen
@@ -687,24 +687,28 @@
 n.xlsx'%0A    
+   
+ 
 in_workbook 
@@ -736,16 +736,20 @@
 lename)%0A
+    
     # %5B'
@@ -758,16 +758,20 @@
 eet 1'%5D%0A
+    
     prin
@@ -800,16 +800,20 @@
 es)%0A    
+ 
+   
 in_sheet
@@ -830,24 +830,28 @@
 book.active%0A
+    
     print('i
@@ -894,24 +894,28 @@
 es%5B0%5D)%0A%0A    
+   
+ 
 out_workbook
@@ -928,16 +928,20 @@
 kbook()%0A
+    
     out_
@@ -964,24 +964,28 @@
 book.active%0A
+    
     out_shee
@@ -1005,24 +1005,28 @@
 _sheet%22%0A    
+ 
+   
 # output fil
@@ -1049,24 +1049,28 @@
 t directory%0A
+    
     out_file
@@ -1088,16 +1088,20 @@
 .xlsx'%0A%0A
+    
     # ht
@@ -1213,16 +1213,20 @@
 yxl-1-6%0A
+    
     firs
@@ -1242,32 +1242,36 @@
 der_row = 2%0A    
+ 
+   
 # column to read
@@ -1287,16 +1287,20 @@
 eet%0A    
+  
+  
 in_colum
@@ -1301,24 +1301,28 @@
 _column = 2%0A
+    
     # column
@@ -1340,24 +1340,28 @@
 n out_sheet%0A
+    
     out_colu
@@ -1368,16 +1368,20 @@
 mn = 1%0A%0A
+    
     for 
@@ -1442,24 +1442,28 @@
 1):%0A        
+    
 in_word = in
@@ -1511,24 +1511,28 @@
 lue%0A        
+  
+  
 out_word = s
@@ -1552,32 +1552,36 @@
 n_word)%0A        
+   
+ 
 print(in_word + 
@@ -1593,24 +1593,28 @@
 + out_word)%0A
+    
         # ou
@@ -1644,16 +1644,20 @@
         
+    
 _ = out_
@@ -1712,16 +1712,20 @@
 _word)%0A%0A
+    
     out_
@@ -1764,8 +1764,30 @@
 ename)%0A%0A
+#read_in_write_out()%0A%0A

Extract code into function read_in_write_out()