0

This is the code that I wrote. I don't understand why I get an error message.

import CSV

import openpyxl

import xlsxwriter

from pandas.io.excel import ExcelWriter

import pandas


def create_excell_from_csv():

arr = ['users', 'account']

dest_filename = r'transformed.xlsx'

wb = xlsxwriter.Workbook(dest_filename)

with ExcelWriter(dest_filename) as ew:

        for arr1 in arr:

            wb.add_worksheet('sh_' + arr1)

            pandas.read_csv(arr1 + '.csv').to_excel(ew, index=FALSE, sheet_name='sh_sh_users' , encoding='utf-8' )

        wb.add_worksheet('Sheet').hide()


create_excell_from_csv()
m00am
  • 5,910
  • 11
  • 53
  • 69
Aviad Amar
  • 13
  • 1
  • 4
  • 1
    What is the error message? – cardamom Jan 17 '18 at 11:19
  • all this: "C:\Program Files\Python36\python.exe" C:/Users/autosrv/Desktop/python_testing/A1.py Traceback (most recent call last): File "C:/Users/autosrv/Desktop/python_testing/A1.py", line 17, in create_excell_from_csv() – Aviad Amar Jan 17 '18 at 12:12
  • and this: File "C:/Users/autosrv/Desktop/python_testing/A1.py", line 14, in create_excell_from_csv pandas.read_csv(arr1 + '.csv').to_excel(ew, index=FALSE, sheet_name='sh_sh_users' , encoding='utf-8' ) File "C:\Program Files\Python36\lib\site-packages\pandas\io\parsers.py", line 709, in parser_f return _read(filepath_or_buffer, kwds) File "C:\Program Files\Python36\lib\site-packages\pandas\io\parsers.py", line 449, in _read parser = TextFileReader(filepath_or_buffer, **kwds) – Aviad Amar Jan 17 '18 at 12:12
  • and this: File "C:\Program Files\Python36\lib\site-packages\pandas\io\parsers.py", line 818, in __init__ self._make_engine(self.engine) File "C:\Program Files\Python36\lib\site-packages\pandas\io\parsers.py", line 1049, in _make_engine self._engine = CParserWrapper(self.f, **self.options) – Aviad Amar Jan 17 '18 at 12:13
  • and this: File "C:\Program Files\Python36\lib\site-packages\pandas\io\parsers.py", line 1695, in __init__ self._reader = parsers.TextReader(src, **kwds) File "pandas\_libs\parsers.pyx", line 562, in pandas._libs.parsers.TextReader.__cinit__ File "pandas\_libs\parsers.pyx", line 790, in pandas._libs.parsers.TextReader._get_header UnicodeDecodeError: 'utf-8' codec can't decode byte 0xee in position 0: invalid continuation byte – Aviad Amar Jan 17 '18 at 12:13
  • Have you looked at this? https://stackoverflow.com/questions/5552555/unicodedecodeerror-invalid-continuation-byte – cardamom Jan 17 '18 at 12:55
  • now it create the excel with the sheets, but theres no data inside of them – Aviad Amar Jan 17 '18 at 13:09

0 Answers0