Category : io

I unzip a file and then try to gzip files from my tmp folder. Once gzipped, I load the files to an S3 bucket. with zipfile.ZipFile(‘/tmp/DataPump_10000838.zip’, ‘r’) as zip_ref: testList = [] for i in zip_ref.namelist(): if (i.startswith("__MACOSX/") == False): val = ‘/tmp/’+i testList.append(val) testList.remove(testList[0]) for i in testList: #zip_ref.open(i, ‘r’) with contextlib.ExitStack() as stack: ..

Read more

I downloaded a zipped file from S3 and unzipped it: with zipfile.ZipFile(‘/tmp/DataPump_10000838.zip’, ‘r’) as zip_ref: testList = [] for i in zip_ref.namelist(): if (i.startswith("__MACOSX/") == False): val = ‘/tmp/’+i testList.append(val) Now, I have a few unzipped files in my /tmp folder. I want to open those files, gzip and move them to an S3 bucket. ..

Read more

I have a few unzipped files in my /tmp folder that I want to open, gzip and move to an S3 bucket. The paths to the unzipped files are present in the testList s3_filename = ‘sample’ s3_resource = boto3.resource(‘s3’) bucket = s3_resource.Bucket(‘testunzipping’) for i in testList: with contextlib.ExitStack() as stack: source_file = stack.enter_context(open(i , mode="rb")) ..

Read more

Uploading from e-mail’s attachments from Gmail to Google Drive: from __future__ import print_function import pickle import os.path from googleapiclient.discovery import build from google_auth_oauthlib.flow import InstalledAppFlow from google.auth.transport.requests import Request import io import base64 from googleapiclient.http import MediaIoBaseUpload from time import sleep q=’has:attachment’ maxResults=int(input("Please specify the number of emails with attachments that you would like to ..

Read more

Uploading from e-mail’s attachments from Gmail to Google Drive: from __future__ import print_function import pickle import os.path from googleapiclient.discovery import build from google_auth_oauthlib.flow import InstalledAppFlow from google.auth.transport.requests import Request import io import base64 from googleapiclient.http import MediaIoBaseUpload from time import sleep q=’has:attachment’ maxResults=int(input("Please specify the number of emails with attachments that you would like to ..

Read more

Uploading from e-mail’s attachments from Gmail to Google Drive: from __future__ import print_function import pickle import os.path from googleapiclient.discovery import build from google_auth_oauthlib.flow import InstalledAppFlow from google.auth.transport.requests import Request import io import base64 from googleapiclient.http import MediaIoBaseUpload from time import sleep q=’has:attachment’ maxResults=int(input("Please specify the number of emails with attachments that you would like to ..

Read more