Am trying to convert csv to xlsx using python 2.7 version but it gives me error like
Traceback (most recent call last):
File "C:/Users/XYZ/Desktop/converter.py", line 13, in <module>
ws.cell(row=r, column=c).value = val
File "C:\Python27\lib\openpyxl\cell\cell.py", line 291, in value
self._bind_value(value)
File "C:\Python27\lib\openpyxl\cell\cell.py", line 190, in _bind_value
value = self.check_string(value)
File "C:\Python27\lib\openpyxl\cell\cell.py", line 149, in check_string
value = unicode(value, self.encoding)
UnicodeDecodeError: 'utf8' codec can't decode byte 0x93 in position 1037: invalid start byte
And My code is
import os
import glob
import csv
import openpyxl
for csvfile in glob.glob(os.path.join('.', 'i.csv')):
wb = openpyxl.Workbook()
ws = wb.active
with open(csvfile, 'rb') as f:
reader = csv.reader(f)
for r, row in enumerate(reader, start=1):
for c, val in enumerate(row, start=1):
ws.cell(row=r, column=c).value = val
wb.save(csvfile + '.xlsx')
Below is the CSV File name i.csv AFFECTED PLATFORM Column Name and 1 row Cell data.
"• Adobe Photoshop CC 2018 version 19.1.3 and earlier. <br />
• Adobe Photoshop CC 2017 version 18.1.3 and earlier for mac OS.<br />
• Adobe Photoshop CC 2017 version 18.1.2 and earlier for Windows.<br />
• Adobe Acrobat DC Consumer version 2018.011.20038 and earlier.<br />
• Adobe Acrobat Reader DC Consumer version 2018.011.20038 and earlier. <br />
• Adobe Acrobat 2017 Classic 2017 version 2017.011.30079 and earlier. <br />
• Adobe Acrobat Reader 2017 Classic 2017 version 2017.011.30079 and earlier. <br />
• Adobe Acrobat DC Classic 2015 version 2015.006.30417 and earlier. <br />
• Adobe Acrobat Reader DC Classic 2015 version 2015.006.30417 and earlier.<br />
"