I'm trying to automate uploading receipt pdfs to google drive, but I'm running into trouble just uploading the pdf in question.
'''ALREADY IMPORTED AND AUTHENTICATED'''
os.chdir('C:\\Users\\sophi\\.spyder-py3-dev\\FishtagScripts')
for file in glob.glob("*.pdf"):
print(file)
with open(file,"r") as f:
fn = os.path.basename(f.name)
file_drive = drive.CreateFile({'title': fn })
file_drive.SetContentString(f.read())
file_drive.Upload()
I expected the pdf to be uploaded to My Drive, but instead it throws the error message UnicodeDecodeError: 'charmap' codec can't decode byte 0x8f in position 762: character maps to