Notice
Recent Posts
Recent Comments
Link
250x250
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | |
7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 | 29 | 30 |
Tags
- 금융소득
- 인덱싱
- boto3
- 산지연금
- pod
- 농지연금
- 신탁공매
- node
- S3
- kubectl
- Resolver
- Filter
- Kubernetes
- 정책자금
- AWS
- 매입불공제
- 임업후계자
- 경매
- 외국납부세액공제
- 성능개선
- 공매
- 양도소득세
- 리소스
- OpenSearch
- 세금계산서
- command
- python
- lambda
- serverless
- route53
Archives
- Today
- Total
진지한 개발자
특정 이름의 S3 파일을 지우고 싶을 때 본문
728x90
- 특정 이름을 가진 S3 파일 리스트 필터링
import boto3
s3 = boto3.resource('s3')
bucket = s3.Bucket('bucket-name')
for file_key in file_list:
print(file_key)
s3.Object('s3-an2-op-hlp-etl', file_key).delete()
- 필터링 된 S3 리스트 내 파일 삭제
import boto3
sess = boto3.Session()
s3 = sess.resource('s3')
operation_bucket = s3.Bucket('bucket-name')
file_list = []
for file in operation_bucket.objects.filter(Prefix=f'test_prefix/'):
if 'filtered_string' in str(file):
file_list.append(file._key)
len(file_list)
728x90
'IT > Python' 카테고리의 다른 글
unzip (0) | 2023.08.26 |
---|---|
S3 file 지우기 (0) | 2023.06.29 |
Convert GroupBy Series to DataFrame (0) | 2023.06.05 |
pip 설치 시 SSLError 오류 해결방법 (SSLCertVerificationError) (0) | 2023.05.22 |
Python 유용한 코드 (0) | 2023.05.20 |