read an excel file and create a final text file from it including polish characters
<p>I need to be able to read in an excel file that has lots of polish characters. Then I need to be able to write this file to a text file keeping the polish characters. 
So far I can only open the file an write it but every time it wants to write the unicode values. As you can see from my code I strip out the u' before I  write the file but the unicode values are another thing.</p>

<p>I end up something like this when I open the text file</p>

<blockquote>
  <p>[29178.0, Firma handlowa', Sklep farbiarsko-chemiczny', A-ZET ZHU
  CIEBIELSKI ZENO', LWOWEK', 7880005802.0, CW PS', \u0141uczak
  Rafa\u0142', ciebielski1@wp.pl', Nie', ', 17242.364799999999, 1061.48,
  0.061562321196220141, Nie', 0.0, 1.0]</p>
</blockquote>

<p>But I want it to look like this...</p>

<blockquote>
  <p>29,178    Firma handlowa  Sklep farbiarsko-chemiczny  A-ZET ZHU CIEBIELSKI
  ZENO  LWOWEK  7880005802  CW PS   Åuczak RafaÅ    ciebielski1@wp.pl   Nie</p>
</blockquote>

<pre><code>wb = xlrd.open_workbook(xl_workbook.xls)

#Get the sheet names  
sheets = wb.sheet_names()

sheet1=[]
for sheet in sheets:     
    sheet1.append(sheet)   

#open the first sheet 

sh = wb.sheet_by_name(sheet1[0])

with open(xl_workbook.txt', "wb") as f:
    stri_line=''
    for rownum in xrange(sh.nrows):
        stri_line=str([val for val in sh.row_values(rownum)])
        stri =str(stri_line.replace("u'",""))

        f.write(stri)
</code></pre>

<p>There must be a way to do this. Any help is very much appreciated. </p>

<p>The string.replace() function is purposely stripping out the unicode chars that would let python know how to to encode those chars. Define the encoding for the file handle, and python will take care of it for you.</p>

<pre><code>with open('xl_workbook.txt', "w", encode="utf-8") as f:
    for rownum in xrange(sh.nrows):
    stri_line=str([val for val in sh.row_values(rownum)])
    f.write(stri)
</code></pre>

python excel text unicode