I have daily file available in GCS bucket in the following pattern and I need to get those blobs for further process.
gs://bucket_name/202112032210/test/a.csv
gs://bucket_name/202112042310/test/b.csv
gs://bucket_name/202112052240/test/a1.csv
So folder name would be : yyyymmdd and then time. Time could be anything and I need to go by each day folder. I am trying to check the file availability for each day using the following pattern but it didn't work :
timestr = str(today.strftime('%Y')) + str(today.strftime('%m')) + str(today.strftime('%d'))
FOLDER_NAME=timestr +'*'+'/test/'
storage_client = storage.Client()
bucket = storage_client.get_bucket()
for blob in storage_client.list_blobs(prefix=FOLDER_NAME):
num = blob.name.count('/')
file_name = blob.name.split('/')[num].strip('.csv')
blob = bucket.blob(blob.name)
print(blob)
But I am not getting the the blobs. Please suggest any workaround for the same to get the folder for each day.