Код: Выделить всё
import io
import pandas as pd
from google.cloud import storage
for project_id in ("project-1", "project-2", "project-3"):
client = storage.Client(project=project_id)
buckets = client.list_buckets()
for bucket in buckets:
blobs = client.list_blobs(bucket)
for blob in blobs:
if blob.name.endswith('.csv'):
csv = blob.download_as_text()
df = pd.read_csv(io.StringIO(csv), low_memory=False)
for col in df.columns:
#finds fields that include 'name'
if 'name' in col.lower():
name_found = df[df[col].str.contains('Bob', case=False, na=False)]
if name_found:
num_found.append(blob.name)
if name_found:
print(f"{len(num_found)} of Bob found in {bucket}. CSV Files are:")
print(f"{num_found}")
else:
print(f"No Bobs found in {bucket}!")
Подробнее здесь: https://stackoverflow.com/questions/792 ... -csv-files