0

I have a dataframe with the the file Ids and the content I want to put in the description. I'm using pydrive and this code works fine for txt files but gives an error when I try to update the description of PNG files. Thanks!

for ind in df.index:
    file1 = drive.CreateFile({'id': df['ID'][ind]})
    file1.Upload()
   # adding to existing description if any
    file1['description'] = file1['description'] + "\n" + df['Content'][ind]
    file1.Upload()
    print('description: %s' % file1['description'])

the error is: in getitem raise KeyError(e) KeyError: KeyError('description')

nandz123
  • 159
  • 12
  • How about confirming the file ID again? Because when the file ID is not correct, also such error occurs. If the file ID is correct, can you provide the detail error messages? – Tanaike Aug 04 '20 at 22:27
  • The file ID is correct because it works for other metadata attributes like titile, etag, etc. – nandz123 Aug 05 '20 at 09:07
  • The full error is: Traceback (most recent call last): File "", line 57, in file1['description'] = file1['description'] + "\n" + df['Content'][ind] File "", line 137, in __getitem__ raise KeyError(e) KeyError: KeyError('description') – nandz123 Aug 05 '20 at 09:47
  • Thank you for replying. Unfortunately, from your error message, I couldn't replicate your situation. This is due to my poor skill. I deeply apologize for this. So can you provide the detail flow for replicating your issue? By this, I would like to test it. – Tanaike Aug 05 '20 at 22:35
  • Thank you @Tanaike, I realized my mistake was I had to use the get function for description so I changed to file1.get('description'), and it worked! – nandz123 Aug 12 '20 at 09:39
  • Thank you for replying. I'm glad your issue was resolved. When your issue was resolved, can you post it as an answer? By this, it will be useful for other users who have the same issue. – Tanaike Aug 12 '20 at 23:42

0 Answers0