Hi Stefan. You could use a dict to hold the conversion values for your Excel. It's less code and it's faster. E.g.:
#!/usr/bin/env python
# You'll need to pip import openpyxl
import openpyxl
excelFile = openpyxl.load_workbook('stefan-data.xlsx')
sheet1 = excelFile.active
convert = {
0: '<10',
0.5: 10,
1: 20,
1.5: 30,
2: 40,
2.5: 60,
3: 80,
3.5: 120,
4: 160,
4.5: 240,
5: 320,
5.5: 480,
6: 640,
6.5: 960,
7: 1280,
7.5: 1920,
8.5: 2560,
}
for row in sheet1.iter_rows():
for cell in row:
if cell.value in convert:
cell.value = convert[cell.value]
excelFile.save('stefan-new-data.xlsx')
And there's no value for 8?
Hi Stefan. You could use a
dictto hold the conversion values for your Excel. It's less code and it's faster. E.g.:And there's no value for
8?