-1

I'm having issues with code that used to work during weeks.

The problem comes from this part of my code:

TypeError: ifile  = open('0_Inputs/CompaniesList.csv', "r", encoding = 'utf-8')

I got the following message:

open() got an unexpected keyword argument 'encoding'

If i try:

ifile  = open('0_Inputs/CompaniesList.csv', "r")

then i have an other error:

OSError: cannot identify image file '0_Inputs/CompaniesList.csv'

Im doing from PyPDF2 import PdfFileReader, PdfFileWriter but I don't if there's a conflict between libraries?

Thank you!

eyllanesc
  • 235,170
  • 19
  • 170
  • 241
B-T
  • 31
  • 1
  • 1
    You are asking about opening PDFs, but you are trying to open a csv? Is the `open()` function you are referring to the built in open? – FlyingTeller Jul 02 '18 at 09:19

1 Answers1

0

You should use the csv module instead of opening the file this way.

with open('0_Inputs/CompaniesList.csv', newline='') as ifile:
    pass

More information: https://docs.python.org/3/library/csv.html

  • Thank you for answering. I got this: TypeError: open() got an unexpected keyword argument 'newline' – B-T Jul 02 '18 at 09:34
  • Did you load the `csv` module? Are you running Python 3? –  Jul 02 '18 at 09:37
  • I did import csv, and I'm running Python 3.6. I can't find where is the problem with the open function. Can it be a conflict with Image from the pillow library? – B-T Jul 02 '18 at 09:50
  • Just delete this argument so… But it is very strange. –  Jul 02 '18 at 09:52