0

the code was running fine with python2 but failing in python3.

with open(inputpath + 'company.csv', 'wb') as outcsv:
        writer = csv.DictWriter(outcsv, delimiter='|',
                                fieldnames=columnlist, quotechar='"',
                                quoting=csv.QUOTE_MINIMAL)
        writer.writeheader()

Error which I am getting :

TypeError: a bytes-like object is required, not 'str'

Any help would be be appreciated!

Shubhankar
  • 95
  • 1
  • 14
  • 2
    Use `w` instead of `wb` while opening file. – Prudhvi Mar 24 '20 at 06:57
  • 2
    Does this answer your question? [TypeError: a bytes-like object is required, not 'str' in python and CSV](https://stackoverflow.com/questions/34283178/typeerror-a-bytes-like-object-is-required-not-str-in-python-and-csv) – ChatterOne Mar 24 '20 at 06:57

0 Answers0