I am trying to write location's address to my excel sheet using xlswriter package in python. The problem I am facing is when I try to run the function using a thread the values are not written to the worksheet. See the below code: Here rows a list containing all the raw address.
import threading
import xlsxwriter
from geopy.geocoders import Nominatim
geolocator = Nominatim()
outputLocation = 'output.xlsx'
workbook = xlsxwriter.Workbook(outputLocation)
w_sheet4 = workbook.add_worksheet('openstreet')
def openstreet():
    p = 1
    for row in rows:        #rows consists of raw addresses
        try:
            rawAddress = str(" ".join(row[1].strip().split())) #here I am normalizing the addresses using openstreet api
            location = geolocator.geocode(rawAddress)
            w_sheet4.write(p, 1, rawAddress)
            w_sheet4.write(p, 2, str(location.address))
        except Exception as e:
            print "OpenStreet", e
        p += 1
t4 = threading.Thread(target=openstreet)
t4.start()
I am able to write to the worksheet if I don't use thread and run the function by calling it. See the below code:
import threading
import xlsxwriter
from geopy.geocoders import Nominatim
geolocator = Nominatim()
outputLocation = 'output.xlsx'
workbook = xlsxwriter.Workbook(outputLocation)
w_sheet4 = workbook.add_worksheet('openstreet')
def openstreet():
    p = 1
    for row in rows:        #rows consists of raw addresses
        try:
            rawAddress = str(" ".join(row[1].strip().split())) #here I am normalizing the addresses using openstreet api
            location = geolocator.geocode(rawAddress)
            w_sheet4.write(p, 1, rawAddress)  #raw address
            w_sheet4.write(p, 2, str(location.address)) #normalize address
        except Exception as e:
            print "OpenStreet", e
        p += 1
#t4 = threading.Thread(target=openstreet)
#t4.start()
openstreet()
The reason I am using thread because I am using multiple APIs (google, yahoo, openstreetmap API , bing) trying to normalize addresses and compare them. Could anyone help me why I am not able to write to the worksheet when I use thread instead of normal function calling.
 
     
    