I have an S3 bucket that I'm saving CSV files for loading them into Redshift. I'm using Python and Boto3 for this. After loading them into Redshift I want to delete specific files that match a pattern that contains the processing ID for my code.
I'm saving my files into S3 bucket as follows
Redshift{processingID}-table1.csv
Redshift{processingID}-table2.csv
Redshift{processingID}-table3.csv
Redshift{processingID}-table4.csv
After processing those files that contains specific ID, I want to delete the processed files from my S3 bucket. How do I specify the pattern.
This is the pattern that I'm trying to delete the files from bucket.
Redshift11-*.csv
. Here 11 is the processingID. How do I delete all the files that matches the pattern using boto3?
I've come across this. https://stackoverflow.com/a/53836093/4626254
But it seems like it is searching for the folder as prefix and not the exact pattern of the file.