Spaces:
Running
Running
VISTA_FOLDER_ID = "10xTrOHOFku5C-MnatdiYuqzBKJXzt4kJ" | |
GEM_FOLDER_ID = "1-rmwZlTklf5w8oNr75Xeb6M1L7RvlS6C" | |
from pydrive.auth import GoogleAuth | |
import pandas as pd | |
from pydrive.drive import GoogleDrive | |
# Rename the downloaded JSON file to client_secrets.json | |
# The client_secrets.json file needs to be in the same directory as the script. | |
gauth = GoogleAuth() | |
drive = GoogleDrive(gauth) | |
# List files in Google Drive | |
fileList = drive.ListFile({'q': f"'{VISTA_FOLDER_ID}' in parents and trashed=false"}).GetList() | |
vista_files = [(file1['title'], file1['id']) for file1 in fileList] | |
fileList = drive.ListFile({'q': f"'{GEM_FOLDER_ID}' in parents and trashed=false"}).GetList() | |
gem_files = [(file1['title'], file1['id']) for file1 in fileList] | |
# Match files by title and create a csv | |
data = [] | |
for vista_file in vista_files: | |
for gem_file in gem_files: | |
if vista_file[0] == gem_file[0]: | |
data.append((vista_file[0], vista_file[1], gem_file[1])) | |
# sort by file_name | |
data.sort(key=lambda x: x[0]) | |
df = pd.DataFrame(data, columns=['file_name', 'vista_id', 'gem_id']) | |
df.to_csv('file_pairs.csv', index=False) |