'How to find modified file and user name on current date in google drive in python by google drive api?

I want to see a dataframe that can show file name, folder name , last modified date i.e today and user modified.

As I have lots of folders and I have to look in all folders to look which file is modified so trying to look in colab or by google_picker_api https://developers.google.com/picker/docs or

by google_drive_api or by google_activity_api here

For example:

for file in drive_folder:
  if file_modified ==current_Date in file.data:
   print(file, user_modifed,date_modifed)

desire_output:

  file_name   folder last_date_modified user_modified
0 spreadsheet abc     20220307           'david'


Solution 1:[1]

In order to gather the list of files, you would need to use the Drive API V3.

I was able to find an example Python code and documentation to utilize query.

One of the examples can allow you to find "Files modified after a given date"

The parameters or fields needed to get the folder, last modified, user and modified would be:

  1. parent: It would give you the ID of the parent folder.
  2. lastModifyingUser: It would give you the information of the user that made the last modification
  3. displayName: For the user that modifies it

You can actually test the API for Drive files.get or files.list

For files.list:

Over the "fields" parameter just add "*" and it would give you all the fields with data about the files of your organization.

For files.get:

You can add the same as above and the ID of any particular file you have.

Sample code edit based on the quickstart for Python.

# Call the Drive v3 API
results = service.files().list(
    pageSize=10,
    fields="parent, files(id, name)",
    q="modifiedTime > '2012-06-04T12:00:00-08:00'").execute()
items = results.get('files', [])
if not items:
    print('No files found.')
else:
    print('Files:')
    for item in items:
        print('{0} ({1})'.format(item['name'], item['id']))

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1