Percentage data from .csv to excel
<p>I read some data under percentage form (11.00%) from a .csv file.
I copy them into an excel file and i want to represent them in a chart.
The problem is, when i copy them into excel, data is automatically converted to string type and i cannot represent them in the chart correctly.
I tried few methods but nothing successfully.</p>

<pre><code>f = open("any.csv")
wb = openpyxl.load_workbook("any.xlsx")
ws = wb.get_sheet_by_name('Sheet1')
reader = csv.reader(f, delimiter=',')

for row in ws.iter_rows(row_offset=0):
        for i in reader:
           ws.append(i[2:]) code here
</code></pre>

<p>I tried using:</p>

<pre><code>for row in ws.iter_rows(row_offset=0): 
   for i in reader: 
      ws.append(float(i[2:])) 
</code></pre>

<p>and i recieve this error:<br>
TypeError: float() argument must be a string or a number </p>

<p>I have tried using:</p>

<pre><code>for i in reader:
       i[2:] = [float(x) for x in i[2:]]
       ws.append(i)
</code></pre>

<p>and i got this eror:
ValueError: invalid literal for float()11.1%</p>

<p>I use the i[2:] because first first and second column contain some text that dont need to be converted</p>

<pre><code>for row in ws.iter_rows(row_offset=0):
        for i in reader:
           ws.append(float(i[2:-1])) code here
</code></pre>

<p>Float the value before you append it</p>

python python-2.7 python-3.x openpyxl