Convert a python list having a mix of unicode values and floating numbers
<p>So I am reading values from an excel and storing inside a list. But by default, it stored strings as unicode strings and numbers as floats. I want to convert unicode strings into normal strings and float to integer. How do I do that?</p>

<p>Here's my list:</p>

<pre><code>import xlrd 
wb = xlrd.open_workbook("test.xlsx")
firstsheet = wb.sheet_by_index(0)
rows =1
rowvalues = []
while(rows &lt;= (firstsheet.nrows)-1):
     rowvalues.extend(firstsheet.row_values(rows)) 
     rows+=1
print rowvalues
</code></pre>

<p>Output:</p>

<pre><code>[121090999.0, 3454554455.0, u'Shantharam', 121090999.0, 5645.0, u'Puranik']
</code></pre>

<p>What I need:</p>

<pre><code>[ 121090999,  3454554455,  'Shantharam', 121090999,  5645,  'Puranik' ]
</code></pre>

<p>Here is a short script that should do the trick:</p>

<pre><code>l=[121090999.0, 3454554455.0, u'Shantharam', 121090999.0, 5645.0, u'Puranik'];
i=0
for i in range(len(l)-1):
        if isinstance(l[i], float):
             l[i]=int(l[i])
        else:
             l[i]=str(l[i])
print(l)
</code></pre>

python unicode xlrd